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

# Get an Order by ID

> Fetch information about an Order once its completed

The `status` of an Order can be one of the following

`Draft` - This is an open or ongoing order

`Processed`* - The payment has been completed.

`Declined`* - The transacation was declined, due to payment method issues

`UserCustody` - Crypto purchased for user but is in Sardine's custodied wallet

`Complete` - The payment is complete and the crypto has been delivered to the user's wallet. A `txHash` will be present to denote successful on chain settlement. 

`Expired` - Order expired before execution

Events marked with an * can also be captured via event handlers on the frontend


### Fetching Orders

Full list of Orders is obtained by making a call to the endpoint with no filters. 


You have multiple options of filtering orders

**1. Filtering by `order_id`**

If a `redirect_url` was passed to the Sardine checkout (e.g. https://crytpoapp.com"), when then transaction is completed, Sardine will redirect the user to this url with an `order_id` appended i.e. https://cryptoapp.com?order_id=73103-erhed-317313

This `order_id` can then be used as a filter on this endpoint

E.g. `/v1/orders/491c113c-4485-47cd-b011-252068b753dc`

**2. Filtering by `referenceId`**
If a `referenceId` was passed in the call to create the `clientToken` for this call, it can now be used to filter for Orders that were created then. 

E.g. `/v1/orders?referenceId=42ead95db5aeb6c`

**3. Filtering by `externalUserId`**

If a `externalUserId` was passed in /auth/client-tokens, it can be used to filter for Orders with that ID. This is useful for associating transactions with a user




**3. Filtering by `startDate` and `endDate`**
If `startDate` or `endDate` are passed in YYYY-MM-DD format, the list of Orders will be filtered to those that were created in this range

E.g. `/v1/orders?startDate=2022-08-01&endDate=2022-08-15`



`paymentStatus` field within the `payment` object in the response can be

- Draft
- Pending

For bank transfers, the value could be

- Sent
- Complete
- Returned
- Failed

For card transactions, the value can be

- Authorized
- Captured
- Declined
- Pending3DS
- Failure3DS
- Voided



## OpenAPI

````yaml /api_reference/onramp.yaml get /orders/{orderId}
openapi: 3.0.3
info:
  version: '1.0'
  title: Crypto API
  description: Reference for Sardine Crypto API
  contact:
    email: support@sardine.io
    name: Sardine
    url: docs.sardine.io
servers:
  - url: https://api.sandbox.sardine.ai/v1
    description: Sandbox
  - url: https://api.sardine.ai/v1
    description: Prod Server
security: []
paths:
  /orders/{orderId}:
    get:
      tags:
        - Order
      summary: Get an Order by ID
      description: >-
        Fetch information about an Order once its completed


        The `status` of an Order can be one of the following


        `Draft` - This is an open or ongoing order


        `Processed`* - The payment has been completed.


        `Declined`* - The transacation was declined, due to payment method
        issues


        `UserCustody` - Crypto purchased for user but is in Sardine's custodied
        wallet


        `Complete` - The payment is complete and the crypto has been delivered
        to the user's wallet. A `txHash` will be present to denote successful on
        chain settlement. 


        `Expired` - Order expired before execution


        Events marked with an * can also be captured via event handlers on the
        frontend



        ### Fetching Orders


        Full list of Orders is obtained by making a call to the endpoint with no
        filters. 



        You have multiple options of filtering orders


        **1. Filtering by `order_id`**


        If a `redirect_url` was passed to the Sardine checkout (e.g.
        https://crytpoapp.com"), when then transaction is completed, Sardine
        will redirect the user to this url with an `order_id` appended i.e.
        https://cryptoapp.com?order_id=73103-erhed-317313


        This `order_id` can then be used as a filter on this endpoint


        E.g. `/v1/orders/491c113c-4485-47cd-b011-252068b753dc`


        **2. Filtering by `referenceId`**

        If a `referenceId` was passed in the call to create the `clientToken`
        for this call, it can now be used to filter for Orders that were created
        then. 


        E.g. `/v1/orders?referenceId=42ead95db5aeb6c`


        **3. Filtering by `externalUserId`**


        If a `externalUserId` was passed in /auth/client-tokens, it can be used
        to filter for Orders with that ID. This is useful for associating
        transactions with a user





        **3. Filtering by `startDate` and `endDate`**

        If `startDate` or `endDate` are passed in YYYY-MM-DD format, the list of
        Orders will be filtered to those that were created in this range


        E.g. `/v1/orders?startDate=2022-08-01&endDate=2022-08-15`




        `paymentStatus` field within the `payment` object in the response can be


        - Draft

        - Pending


        For bank transfers, the value could be


        - Sent

        - Complete

        - Returned

        - Failed


        For card transactions, the value can be


        - Authorized

        - Captured

        - Declined

        - Pending3DS

        - Failure3DS

        - Voided
      operationId: get-order-order_id
      parameters:
        - name: referenceId
          in: query
          description: >-
            If a `referenceId` is passed when creating the `clientToken`, it can
            be used as a filter
          schema:
            type: string
            format: uuid
        - name: limit
          in: query
          description: Number of results returned
          schema:
            type: string
        - name: startDate
          in: query
          description: Date in YYYY-MM-DD
          schema:
            type: string
        - name: endDate
          in: query
          description: Date in YYYY-MM-DD
          schema:
            type: string
        - name: externalUserId
          in: query
          description: >-
            Filter using `externalUserId` to obtain all Orders associated with a
            particular user
          schema:
            type: string
            format: uuid
        - name: orderId
          in: path
          description: ID of Order
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  createdAt:
                    type: string
                  confirmedAt:
                    type: string
                  referenceId:
                    type: string
                  status:
                    type: string
                  fiatCurrency:
                    type: string
                  transactionId:
                    type: string
                  walletAddress:
                    type: string
                  expiresAt:
                    type: string
                  userId:
                    type: string
                  total:
                    type: integer
                  subtotal:
                    type: integer
                  processingFees:
                    type: object
                    properties:
                      transactionFee:
                        type: integer
                      networkFee:
                        type: number
                  payment:
                    type: object
                    properties:
                      amountCents:
                        type: integer
                      currency:
                        type: string
                      paymentMethodId:
                        type: string
                      paymentMethodType:
                        type: string
                  withdrawal:
                    type: object
                    properties:
                      txHash:
                        type: string
                      walletAddress:
                        type: string
                      quantity:
                        type: number
                  withdrawals:
                    type: array
                    description: Sample
                    items:
                      type: object
                      properties:
                        walletAddress:
                          type: string
                        holdAmount:
                          type: integer
                        holdUntil:
                          type: string
                        quantity:
                          type: number
                        isHold:
                          type: boolean
                        status:
                          type: string
                        txHash:
                          type: string
                        withdrawnAt:
                          type: string
                x-examples:
                  Example 1:
                    id: 0113e40a-7406-4036-a882-745a3275e614
                    createdAt: '2023-03-10T20:46:29Z'
                    confirmedAt: '2023-03-10T20:46:33Z'
                    referenceId: test-0.7142516498128628
                    status: Complete
                    fiatCurrency: USD
                    transactionId: 7b47afca-4a6d-4cd3-a756-03db3281b932
                    walletAddress: '0x3d0babc12ac0b08f933a837dbb7a9943be35b0fc'
                    expiresAt: '2023-03-10T20:51:29Z'
                    userId: afceb64d-2d0b-4e52-8b99-a6a4eafc8515
                    total: 10
                    subtotal: 0
                    processingFees:
                      transactionFee: 0
                      networkFee: 1.05
                    payment:
                      amountCents: 1000
                      currency: USD
                      paymentMethodId: cfb30490-62da-4bcb-8179-5e18953d0117
                      paymentMethodType: Bank
                    withdrawal:
                      txHash: >-
                        0xbb45ae53e0ca10e598cf9d0ffedf554e8a72ca4a611a3f883474e0d6864eda5a
                      walletAddress: '0x3d0babc12ac0b08f933a837dbb7a9943be35b0fc'
                    withdrawals:
                      - walletAddress: '0x3d0babc12ac0b08f933a837dbb7a9943be35b0fc'
                        holdAmount: 5
                        holdUntil: '2023-03-14T20:46:14.675+00:00'
                        quantity: 0.003091455
                        isHold: true
                        status: HOLD
                      - txHash: >-
                          0xbb45ae53e0ca10e598cf9d0ffedf554e8a72ca4a611a3f883474e0d6864eda5a
                        walletAddress: '0x3d0babc12ac0b08f933a837dbb7a9943be35b0fc'
                        quantity: 0.003091455
                        isHold: false
                        status: SETTLED
                        withdrawnAt: '2023-03-10T20:46:58Z'
      security:
        - ClientToken: []
      servers:
        - url: https://api.sandbox.sardine.ai/v1
          description: Sandbox
        - url: https://api.sardine.ai/v1
          description: Prod Server
components:
  securitySchemes:
    ClientToken:
      type: http
      scheme: basic

````