{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/carbonmark-com/json-schema/carbonmark-com-order-schema.json",
  "title": "Order",
  "x-generated": "2026-11-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/carbonmark-com-openapi.json#/components/schemas/Order",
  "type": "object",
  "properties": {
    "created_at": {
      "type": "string"
    },
    "updated_at": {
      "type": "string"
    },
    "status": {
      "description": "Status of the order.",
      "anyOf": [
        {
          "title": "SUBMITTED",
          "description": "Status of the order: Order created.",
          "type": "string",
          "enum": [
            "SUBMITTED"
          ]
        },
        {
          "title": "INITIATED",
          "description": "Status of the order: Order taken into account by our bots.",
          "type": "string",
          "enum": [
            "INITIATED"
          ]
        },
        {
          "title": "COMMITTED",
          "description": "Status of the order: Transaction committed to the blockchain.",
          "type": "string",
          "enum": [
            "COMMITTED"
          ]
        },
        {
          "title": "MINTED",
          "description": "Status of the order: Transaction confirmed on the blockchain.",
          "type": "string",
          "enum": [
            "MINTED"
          ]
        },
        {
          "title": "COMPLETED",
          "description": "Status of the order: Transaction indexed.",
          "type": "string",
          "enum": [
            "COMPLETED"
          ]
        },
        {
          "title": "FAILED",
          "description": "Transaction failed.",
          "type": "string",
          "enum": [
            "FAILED"
          ]
        }
      ],
      "type": "string"
    },
    "consumption_metadata": {
      "description": "Puro.Earth specific data for the order.",
      "type": "object",
      "properties": {
        "retiring_address": {
          "description": "Address to retire the carbon credits to.",
          "type": "string"
        },
        "country_of_consumption": {
          "description": "ISO 3166 country of consumption.",
          "type": "string"
        },
        "country_of_consumption_code": {
          "description": "ISO 3166 Alpha 2 country of consumption code.",
          "type": "string"
        },
        "consumption_period_start": {
          "description": "Start of the consumption period in unix seconds",
          "type": "number"
        },
        "consumption_period_end": {
          "description": "End of the consumption period in unix seconds.",
          "type": "number"
        }
      }
    },
    "registry_specific_data": {
      "description": "Registry specific data for the order.",
      "type": "object",
      "properties": {
        "puro_earth": {
          "description": "Puro specific data for the order.",
          "type": "object",
          "properties": {
            "puro_batch_token_id": {
              "description": "Puro batch token ID.",
              "type": "string"
            }
          }
        }
      }
    },
    "completed_at": {
      "anyOf": [
        {
          "description": "Time the transaction was confirmed on the blockchain if the transaction completed successfully.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "transaction_hash": {
      "anyOf": [
        {
          "description": "Hash of the transaction related to this order.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "retirement_message": {
      "anyOf": [
        {
          "description": "Message associated with the retirement.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "retirement_index": {
      "anyOf": [
        {
          "description": "Index of the retirement for the given beneficiary address",
          "type": "number"
        },
        {
          "type": "null"
        }
      ]
    },
    "beneficiary_name": {
      "anyOf": [
        {
          "description": "Beneficiary of the retirement.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "beneficiary_address": {
      "anyOf": [
        {
          "description": "Wallet address to which the retirement will be attributed to.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "on_chain_explorer_url": {
      "anyOf": [
        {
          "description": "URL of the retirement transaction on the appropriate on-chain explorer",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "view_retirement_url": {
      "anyOf": [
        {
          "description": "URL on Carbonmark to view and download the retirement certificate.",
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "quote": {
      "$ref": "#/$defs/Quote"
    }
  },
  "required": [
    "created_at",
    "updated_at",
    "status",
    "consumption_metadata",
    "registry_specific_data",
    "quote"
  ],
  "$defs": {
    "Quote": {
      "type": "object",
      "properties": {
        "uuid": {
          "description": "Reference of the quote. use this in the `POST /orders` endpoint if you want to create an order from this quote.",
          "type": "string"
        },
        "created_at": {
          "type": "string"
        },
        "updated_at": {
          "type": "string"
        },
        "credential_id": {
          "description": "ID of the credentials used to create this quote.",
          "type": "number"
        },
        "asset_price_source_id": {
          "description": "ID of the asset price source.",
          "type": "string"
        },
        "quantity_tonnes": {
          "description": "Number of tonnes quoted.",
          "type": "number"
        },
        "cost_usdc": {
          "description": "Amount in USD which will be invoiced if this quote is converted to an order.",
          "type": "number"
        },
        "consumed": {
          "description": "Equals 1 if this quote was used to create an order, 0 otherwise. A consumed quote can no longer be used to create an order.",
          "type": "number"
        }
      },
      "required": [
        "uuid",
        "created_at",
        "updated_at",
        "credential_id",
        "asset_price_source_id",
        "quantity_tonnes",
        "cost_usdc",
        "consumed"
      ]
    }
  }
}