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

# Quote

> Generates a real-time rate proposal for a new hedge associated with the specified customer. Once accepted, this proposal becomes a confirmed hedge.



## OpenAPI

````yaml POST /customers/{customerId}/hedges/quote
openapi: 3.1.0
info:
  title: Grain API
  version: 1.0.0
  description: >-
    Grain's API provides a comprehensive set of endpoints for managing hedging,
    spot transactions, pricing, and fund movements - enabling seamless
    integration of FX workflows into your platform. Each API call follows REST
    conventions, uses secure authentication, and returns standardized responses
    for consistency across environments.
  license:
    name: Creative Commons Attribution 3.0
  contact:
    name: Grain Finance
    url: https://docs.grainfinance.co
    email: support@grainfinance.co
  termsOfService: https://grainfinance.co/terms-of-service/
  x-apiClientRegistration:
    url: https://grainfinance.co/partners
servers:
  - url: https://api.grainfinance.co/v1
    description: Grain API
security: []
tags:
  - name: Hedges
    description: >-
      Hedge objects represent transactions that lock exchange rates for future
      dates. A single hedge locks an exchange rate for a future transaction
      between two currencies.
  - name: Dual Hedges
    description: >-
      A dual hedge mitigates FX risk by automatically generating two linked
      hedge legs - a customer leg and a supplier leg - both routed through the
      customer's functional currency. This structure reduces exposure to
      currency fluctuations for both cash flow and accounting purposes, while
      allowing independent tracking and reporting of each hedge leg.
  - name: Customers
    description: >-
      Customer objects represent your end customers on the Grain platform. A
      customer must be created before a hedge or spot transaction can be
      initiated.
  - name: Pricing
    description: >-
      Pricing endpoints provide access to FX rates for currency pairs that are
      not being hedged. These endpoints can be used for live rate display or
      bulk retrieval to support high-volume quoting workflows.
  - name: Spots
    description: >-
      Spot objects represent currency conversions executed for immediate or
      near-term settlement.
  - name: Conversions
    description: >-
      Conversion objects represent currency conversions executed for immediate
      or near-term settlement.
  - name: Wallets
    description: Endpoints to view balances, manage funding, and perform transfers.
paths:
  /customers/{customerId}/hedges/quote:
    post:
      tags:
        - Hedges
      description: >-
        Generates a real-time rate proposal for a new hedge associated with the
        specified customer. Once accepted, this proposal becomes a confirmed
        hedge.
      operationId: Real-time Quote
      parameters:
        - description: The id of the customer within the Grain platform.
          in: path
          name: customerId
          required: true
          schema:
            type: string
        - in: header
          name: X-Customer-IP
          required: true
          schema:
            $ref: '#/components/schemas/CustomerIP'
      requestBody:
        description: The payload required in order to ask for a hedge quote
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/HedgeQuoteRequestBody'
              description: The payload required in order to ask for a hedge quote
            examples:
              toCurrencyAmount:
                value:
                  fromCurrency: MXN
                  toCurrency: USD
                  toCurrencyAmount: 1560
                  externalMarkupPct: 1
                  endAt: '2023-02-23'
              fromCurrencyAmount:
                value:
                  fromCurrency: MXN
                  toCurrency: USD
                  fromCurrencyAmount: 25000
                  externalMarkupPct: 1
                  endAt: '2023-02-23'
      responses:
        '201':
          description: Hedge Proposal Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreatedCustomerHedgeProposalResponseBody'
              examples:
                toCurrencyAmount:
                  value:
                    id: 497f6eca-6276-4993-bfeb-53cbbbba6f08
                    fromCurrency: MXN
                    toCurrency: USD
                    quote: 20.6165
                    validUntilTs: 1659625098
                    endAt: '2023-04-15'
                    initialCollateralPercentage: 5
                    toCurrencyAmount: 1560
                    fromCurrencyAmount: 32161.8
                    fixedSide: toCurrencyAmount
                    externalMarkupPct: 1
                fromCurrencyAmount:
                  value:
                    id: 497f6eca-6276-4993-bfeb-53cbbbba6f08
                    fromCurrency: MXN
                    toCurrency: USD
                    quote: 20.6165
                    validUntilTs: 1659625098
                    endAt: '2023-04-15'
                    initialCollateralPercentage: 5
                    toCurrencyAmount: 1560
                    fromCurrencyAmount: 32161.8
                    fixedSide: fromCurrencyAmount
                    externalMarkupPct: 1
        '400':
          description: >-
            The request failed because it is not well-formed or is syntactically
            incorrect or violates schema.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: The request failed because the resource does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '409':
          description: The request failed because a business rule constraint was violated.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '412':
          description: The request failed because one or more preconditions were not met.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: >-
            The request failed because it is either semantically incorrect or
            has failed business validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '451':
          description: The request failed due to legal restrictions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RejectedByIPError'
      security:
        - api-key: []
components:
  schemas:
    CustomerIP:
      type: string
      format: IPv4
      description: >-
        The IPv4 address of the browser from which the customer contacts your
        platform. <br />

        _example_: `192.158.1.38`
      pattern: ((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}
    HedgeQuoteRequestBody:
      description: Information required by Grain in order to generate a hedge proposal.
      properties:
        fromCurrency:
          type: string
          description: >-
            The currency in which the transaction should be paid at by your
            customer.
          example: MXN
        toCurrency:
          type: string
          description: >-
            The currency in which the inventory item is listed at on your
            platform.
          example: USD
        toCurrencyAmount:
          type: number
          format: double
          description: >-
            Specifies the amount to hedge in the toCurrency.

            When provided, this sets fixedSide to toCurrencyAmount, and the
            fromCurrencyAmount is derived as:

            fromCurrencyAmount = toCurrencyAmount × quote.

            Exactly one of toCurrencyAmount or fromCurrencyAmount may be
            provided.

            Alternatively, neither may be provided to defer amount specification
            to the Accept call.
          example: 1560
        fromCurrencyAmount:
          type: number
          format: double
          description: >-
            Specifies the amount to hedge in the fromCurrency.

            When provided, this sets fixedSide to fromCurrencyAmount, and the
            toCurrencyAmount is derived as:

            toCurrencyAmount = fromCurrencyAmount / quote.

            Exactly one of toCurrencyAmount or fromCurrencyAmount may be
            provided.

            Alternatively, neither may be provided to defer amount specification
            to the Accept call.
        externalMarkupPct:
          type: number
          format: double
          description: >-
            The external markup percentage that should be added to this quote on
            top of Grain’s internal pricing.

            For example, a value of 1.0 represents a 1.0% additional markup.
          example: 1
        endAt:
          $ref: '#/components/schemas/GrainDateFormat'
          description: >-
            The date in which the hedge will be settled, denoted in `YYYY-MM-DD`
            format.
          example: '2023-02-23'
      required:
        - fromCurrency
        - toCurrency
        - endAt
      type: object
      additionalProperties: false
    CreatedCustomerHedgeProposalResponseBody:
      properties:
        id:
          $ref: '#/components/schemas/UUID'
          description: The id of the hedge proposal within the Grain platform.
          example: 8173b9a7-ee61-413e-b9e3-7c04b2a067c5
        fromCurrency:
          type: string
          description: >-
            The currency in which the transaction should be paid at by your
            customer.
          example: MXN
        toCurrency:
          type: string
          description: >-
            The currency in which the inventory item is listed at on your
            platform.
          example: USD
        quote:
          type: number
          format: double
          description: The rate locked by this hedge.
          example: 20.6165
        validUntilTs:
          type: number
          format: double
          description: The unix timestamp until which the hedge offer is valid.
          example: 1659625098
        endAt:
          $ref: '#/components/schemas/GrainDateFormat'
          description: >-
            The date in which the hedge will be settled, denoted in `YYYY-MM-DD`
            format.
          example: '2023-02-23'
        initialCollateralPercentage:
          type: number
          format: double
          description: >-
            The percentage from the overall amount of collateral required to
            perform this hedge at inception.
          example: 5
        toCurrencyAmount:
          type: number
          format: double
          description: >-
            The amount to hedge in the toCurrency.

            If fromCurrencyAmount is provided, then toCurrencyAmount calculated
            as:

            `toCurrencyAmount = fromCurrencyAmount / quote`

            Only present if an amount was provided at quote time.
          example: 1560
        fromCurrencyAmount:
          type: number
          format: double
          description: >-
            The amount to hedge in the fromCurrency.

            If toCurrencyAmount is provided, then fromCurrencyAmount calculated
            as:

            `fromCurrencyAmount = toCurrencyAmount * quote`

            Only present if an amount was provided at quote time.
          example: 32161.8
        fixedSide:
          $ref: '#/components/schemas/DisplayFixedSide'
          description: >-
            Indicates which currency amount was fixed (specified) when creating
            the quote.

            When `fixedSide` is `toCurrencyAmount`, the `toCurrencyAmount` was
            specified and `fromCurrencyAmount` was calculated.

            When `fixedSide` is `fromCurrencyAmount`, the `fromCurrencyAmount`
            was specified and `toCurrencyAmount` was calculated.

            Only present if an amount was provided at quote time.
          example: toCurrencyAmount
        externalMarkupPct:
          type:
            - number
            - 'null'
          format: double
          description: >-
            The external markup percentage that should be added to this quote on
            top of Grain's internal pricing.

            For example, a value of 1.0 represents a 1.0% additional markup.
          example: 1
      required:
        - id
        - fromCurrency
        - toCurrency
        - quote
        - validUntilTs
        - endAt
        - initialCollateralPercentage
        - externalMarkupPct
      type: object
      additionalProperties: false
    ErrorResponse:
      description: An API Error
      properties:
        message:
          type: string
          description: A short explanation of the error.
          example: Can't perform this action
        reason:
          type: string
          description: A detailed description of the reason for the failure.
          example: >-
            Supplied object is in *Cancelled* state, which prevents performing
            this action
      required:
        - message
      type: object
      additionalProperties: false
    RejectedByIPError:
      properties:
        message:
          type: string
          description: A short explanation of the error.
          example: Could not parse IP address (v4 or v6) for ip
      required:
        - message
      type: object
      additionalProperties: false
    GrainDateFormat:
      type: string
      example: '2023-04-15'
      format: YYYY-MM-DD
      description: >-
        The date format accepted by Grain's API. We accept dash separated
        ISO-8601 date-only strings.
      pattern: \d{4}-\d{2}-\d{2}
    UUID:
      type: string
      format: uuid
      description: |-
        Stringified UUIDv4.
        See [RFC 4112](https://tools.ietf.org/html/rfc4122)
      pattern: >-
        [0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-4[0-9A-Fa-f]{3}-[89ABab][0-9A-Fa-f]{3}-[0-9A-Fa-f]{12}
    DisplayFixedSide:
      description: |-
        The fixed side as displayed in external APIs (camelCase format).
        Indicates which currency amount was specified when creating the hedge.
      enum:
        - toCurrencyAmount
        - fromCurrencyAmount
      type: string
  securitySchemes:
    api-key:
      type: http
      scheme: basic
      description: >-
        Basic authentication using the partner API keys from
        https://console.grainfinance.co/keys

````