> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cnaught.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Quote for Train Emissions

> Get a price quote for offsetting train carbon emissions.
Will return the amount of CO₂e to offset and total price.




## OpenAPI

````yaml /api-reference/openapi.yaml post /quotes/train
openapi: 3.1.0
info:
  title: CNaught Carbon Credits API Documentation
  contact:
    email: support@cnaught.com
    name: CNaught
    url: https://cnaught.com/
  version: v1
  description: |
    Carbon Credits API Documentation
  termsOfService: https://cnaught.com/terms
  license:
    name: MIT
    url: https://spdx.org/licenses/MIT.html
servers:
  - url: https://api.cnaught.com/v1
    description: CNaught API
security:
  - ApiKey: []
tags:
  - name: Orders
    description: Endpoints for placing orders and retrieving information about orders
  - name: Quotes
    description: Endpoints for obtaining price quotes for orders
  - name: Climate Impact
    description: >-
      Endpoints for retrieving climate impact data and hosted public impact page
      configuration
  - name: Subaccounts
    description: Endpoints for creating and retrieving information about subaccounts
paths:
  /quotes/train:
    post:
      tags:
        - Quotes
      summary: Get Quote for Train Emissions
      description: |
        Get a price quote for offsetting train carbon emissions.
        Will return the amount of CO₂e to offset and total price.
      operationId: RequestTrainQuote
      parameters:
        - $ref: '#/components/parameters/QuoteSubaccountId'
      requestBody:
        description: Quote Parameters
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TrainQuoteParams'
            examples:
              Example:
                value:
                  distance_km: 500.5
      responses:
        '200':
          description: Quote Details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Quote'
              example:
                amount_kg: 15
                price_usd_cents: 2350
        '400':
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/BadRequestProblemDetails'
              examples:
                Invalid Parameters:
                  value:
                    errors:
                      distance_km:
                        - '''distance_km'' must be greater than 0'
                    type: https://api.cnaught.com/v1/errors/invalid-parameters
                    title: Your request parameters didn't validate
                    status: 400
                Invalid Subaccount:
                  value:
                    type: https://api.cnaught.com/v1/errors/invalid-subaccount
                    title: The subaccount ID you provided is invalid
                    detail: Subaccount '5nubL0NS' does not exist
                    status: 400
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/PortfolioNotFound'
components:
  parameters:
    QuoteSubaccountId:
      name: X-Subaccount-Id
      in: header
      required: false
      description: >-
        If present, the quote is priced for the subaccount with the given id,
        which means it uses that subaccount's default portfolio if it has one.
        Pass the same subaccount id when you place the order, so that the price
        you were quoted is the price you are charged. Sending the header with a
        blank value is treated the same as leaving it out, and prices for the
        whole organization. An id that does not belong to your organization is
        rejected with a `400 invalid-subaccount`. See
        [Subaccounts](/api/reference/#tag/Subaccounts) for more info.
      schema:
        type: string
  schemas:
    TrainQuoteParams:
      type: object
      required:
        - distance_km
      properties:
        distance_km:
          type: number
          description: Distance of train ride, in km
          examples:
            - 5
        portfolio_id:
          type:
            - string
            - 'null'
          description: >-
            Optional ID of the portfolio to use for the quote. The quote will be
            for an order fulfilled from this portfolio. If not specified, the
            account's default portfolio will be used.
          examples:
            - a23bF6
        source:
          type:
            - string
            - 'null'
          description: >
            Optional source of the quote. Defaults to `api` if not specified,
            otherwise must be one of `api` or `checkout`.

            Use `api` if the eventual order will be placed via the Order API.
            Use `checkout` if the order will be placed using the Checkout
            Session API.
          examples:
            - api
            - checkout
    Quote:
      properties:
        amount_kg:
          type: number
          description: Amount of carbon credits the quote is for, in kilograms
          examples:
            - 10.5
        price_usd_cents:
          type: number
          description: Price charged for the credits, in USD cents
          examples:
            - 2350
    BadRequestProblemDetails:
      allOf:
        - $ref: '#/components/schemas/BaseProblemDetails'
        - type: object
          properties:
            errors:
              description: >-
                Invalid properties object where each property is the key, mapped
                to a list of reasons why the property is invalid
              type:
                - object
                - 'null'
              additionalProperties:
                type: array
                items:
                  type: string
    BaseProblemDetails:
      type: object
      description: Problem details object returned on errors
      properties:
        title:
          type: string
          description: Short, human-readable summary of the problem
        details:
          type: string
          description: Longer, human-readable description of the problem
        type:
          type: string
          description: URI that identifies the problem type
        status:
          type: integer
          description: HTTP status code of the error
  responses:
    Unauthorized:
      description: Request Unauthorized
      content:
        application/problem+json:
          schema:
            properties:
              title:
                type: string
                description: Short, human-readable summary of the problem type
              status:
                type: integer
                description: HTTP status code of the error
          example:
            title: Authorization has been denied for this request
            status: 401
    PortfolioNotFound:
      description: Portfolio Not Found
      content:
        application/problem+json:
          schema:
            $ref: '#/components/schemas/BaseProblemDetails'
          example:
            type: https://api.cnaught.com/v1/errors/not-found
            title: Could not find portfolio
            status: 404
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````