> ## 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 Order(s)

> 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

`Expired`* - The user didn't complete the transaction within the `expiration` time

`Processed`* - The payment has been completed.

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

`Cancelled`* - The transaction did not complete, which could be for a number of reasons, as outlined in the reason codes below. 

`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. 

`Refunded` - The User's payment has been refunded to their original payment method


### For Smart Contract Integrations

Orders might end up in `Cancelled` state, due to a number of reasons, which Sardine will share through a `reasonCode` parameter as part of an `error` object in the Order. After an Order has been Cancelled, it will move to the `Refunded` state

The following reason codes might appear

`NETF` - Network Failure
`PRCC` - Price Change beyond threshold
`RISD` - Risk Decline
`NA` - NFT Not Available


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 `orderId`
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, this form
https://api.sandbox.sardine.ai/v1/orders/3103-erhed-317313


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. 

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

4. Filtering by `externalUserId`




## OpenAPI

````yaml /api_reference/nft.yaml get /orders
openapi: 3.1.0
info:
  version: '1.0'
  title: NFT API
  summary: API to enable direct NFT purchasing
  description: Reference for Sardine Crypto API
servers:
  - url: https://api.sandbox.sardine.ai/v1
    description: Sandbox
  - url: https://api.sardine.ai/v1
    description: Prod Server
security:
  - {}
paths:
  /orders:
    get:
      summary: Get Order(s)
      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


        `Expired`* - The user didn't complete the transaction within the
        `expiration` time


        `Processed`* - The payment has been completed.


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


        `Cancelled`* - The transaction did not complete, which could be for a
        number of reasons, as outlined in the reason codes below. 


        `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. 


        `Refunded` - The User's payment has been refunded to their original
        payment method



        ### For Smart Contract Integrations


        Orders might end up in `Cancelled` state, due to a number of reasons,
        which Sardine will share through a `reasonCode` parameter as part of an
        `error` object in the Order. After an Order has been Cancelled, it will
        move to the `Refunded` state


        The following reason codes might appear


        `NETF` - Network Failure

        `PRCC` - Price Change beyond threshold

        `RISD` - Risk Decline

        `NA` - NFT Not Available



        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 `orderId`

        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, this form

        https://api.sandbox.sardine.ai/v1/orders/3103-erhed-317313



        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. 


        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


        4. Filtering by `externalUserId`
      operationId: get-orders
      parameters:
        - name: reference
          in: query
          description: Unique ID that was passed when creating the order
          schema:
            type: string
        - name: startData
          in: query
          description: >-
            Date in YYYY-MM-DD format that can be used to filter by time,
            starting with this date
          schema:
            type: string
        - name: endDate
          in: query
          description: >-
            Date in YYYY-MM-DD format that can be used to filter by time, ending
            with this date
          schema:
            type: string
        - name: externalUserId
          in: query
          description: >-
            Unique ID created by developer that is passed when creating the
            client token. Non unique
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  createdAt:
                    type: string
                  referenceId:
                    type: string
                  status:
                    type: string
                  expiresAt:
                    type: string
                  userId:
                    type: string
                  total:
                    type: integer
                  subtotal:
                    type: number
                  processingFees:
                    type: object
                    properties:
                      tax:
                        type: number
                      clientProcessingFee:
                        type: number
                      networkFee:
                        type: number
                  payment:
                    type: object
                    properties:
                      currency:
                        type: string
                      paymentMethodType:
                        type: string
                  data:
                    type: object
                    properties:
                      transactionType:
                        type: string
                      name:
                        type: string
                      price:
                        type: string
                      contractAddress:
                        type: string
                      imageUrl:
                        type: string
                  error:
                    type: object
                    properties:
                      reasonCode:
                        type: string
                        description: >-
                          Reason code if Order is in `Declined`, `Cancelled` or
                          `Refunded`
                x-examples:
                  example-1:
                    id: 4971a540-9700-47db-93c3-48a179c25b53
                    createdAt: '2022-08-09T18:58:55Z'
                    referenceId: fff123121123dff12332
                    status: Expired
                    expiresAt: '2022-08-09T19:58:55Z'
                    userId: 890a7f-akjsdi983-aps389df87
                    total: 500
                    subtotal: 498.6
                    processingFees:
                      tax: 0.1
                      clientProcessingFee: 1.2
                      networkFee: 0.1
                    payment:
                      currency: USD
                      paymentMethodType: credit
                    data:
                      transactionType: nft
                      name: The BEST NFT FOR DEMO PURPOSE
                      price: '498.6'
                      contractAddress: '0x7fC0344254E1663C2eF24e3c063cbec231525C20'
                      imageUrl: >-
                        https://www.dictionary.com/e/wp-content/uploads/2018/03/This-is-Fine-300x300.jpg
                    withdrawal:
                      txHash: >-
                        0x36e38af93e08388fb8140ccaf7e4c6fef2234d5b3f9dc6ace39c53859f9da37d
                      walletAddress: '0x5e14dfdb3438676255f0e4137c627c73bc7551a0'
              examples:
                Get Order by Reference ID:
                  value:
                    id: 4971a540-9700-47db-93c3-48a179c25b53
                    createdAt: '2022-08-09T18:58:55Z'
                    referenceId: fff123121123dff12332
                    status: Expired
                    expiresAt: '2022-08-09T19:58:55Z'
                    userId: 890a7f-akjsdi983-aps389df87
                    total: 500
                    subtotal: 498.6
                    processingFees:
                      tax: 0.1
                      clientProcessingFee: 1.2
                      networkFee: 0.1
                    payment:
                      currency: USD
                      paymentMethodType: credit
                    data:
                      transactionType: nft
                      name: The BEST NFT FOR DEMO PURPOSE
                      price: '498.6'
                      contractAddress: '0x7fC0344254E1663C2eF24e3c063cbec231525C20'
                      imageUrl: >-
                        https://www.dictionary.com/e/wp-content/uploads/2018/03/This-is-Fine-300x300.jpg
      security:
        - {}
      servers:
        - url: https://api.sandbox.sardine.ai/v1
          description: Sandbox
        - url: https://api.sardine.ai/v1
          description: Prod Server

````