Skip to main content

Receipts

Generated HTTP reference for the 2 operations the published OpenAPI document describes under receipts.

2 min read
View MarkdownEdit on GitHub

Receipts

This page is generated from the published OpenAPI document. It is complete with respect to that document and says nothing about surfaces the document does not describe yet. See what is generated here for what that means.

Base URL: https://api.codespar.dev

Every operation below requires a Bearer token. See Authentication.

A receipt is the signed record of one spend: the mandate that authorized it, the quote the agent accepted, the payment that settled, and the delivery proof when one lands, chained by a hash and signed with the same consumer secret that signed the mandate. Its id (rcpt_...) comes back on the spend that sealed it: the receipt_id field of the payment response, the receipt object of a codespar_pay result, or codespar_ledger with action: "receipt". What a receipt is, which spend paths seal one and which do not, and the receipt reads that exist in the code but not in this document are on the concept page, Mandates, receipts and approvals.

Every operation, from the spec

Generated from the published OpenAPI document, so it never drifts from what the API actually serves. The section above is written by hand and carries what a schema cannot: the object model, field rules, and the order to call things in.

GET /v1/consumers/receipts/{id}

GEThttps://api.codespar.dev/v1/consumers/receipts/{id}

Read one agentic receipt

Path parameters

NameTypeRequiredDescription
idstringyesThe receipt id.

Responses

StatusBodyDescription
200objectOK
404objectNo receipt with this id in this project. A receipt in another project of the same organization answers the same way.

Response 200

FieldTypeRequiredDescription
chainstringyes
deliveryobject,nullyesNull until a delivery proof has been sealed onto the receipt.
exceptionsarray of objectyes
mandateobjectyes
paymentobjectyes
quoteobject,nullyesNull when the receipt carries neither a seller nor a resource.
receipt_idstringyes
receipt_sigstringyes
state"paid" | "delivered" | "exception" | "voided"yes
Example request
curl -X GET https://api.codespar.dev/v1/consumers/receipts/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
const res = await fetch("https://api.codespar.dev/v1/consumers/receipts/{id}", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
  },
});

const data = await res.json();
const result = await cs.api.get("/v1/consumers/receipts/{id}", {
  path: {
    id: "receipt_0000000000000000"
  }
});
Example response 200
application/json
{
  "receipt_id": "receipt_0000000000000000",
  "state": "paid",
  "mandate": {
    "id": "obj_0000000000000000",
    "nonce": "string",
    "scope": "string",
    "currency": "BRL",
    "sig": "string"
  },
  "quote": {},
  "payment": {
    "rail": "string",
    "amount_minor": 1000,
    "amount_authorized": "1000",
    "amount_charged": "1000",
    "amount_refunded": "1000",
    "metering": {
      "basis": "string",
      "units": "string",
      "unit_price": "string"
    },
    "sandbox": true,
    "attempt_id": "attempt_0000000000000000",
    "money_moved": true,
    "at": "string"
  },
  "delivery": {
    "result": "confirmed"
  },
  "chain": "string",
  "receipt_sig": "string",
  "exceptions": [
    {
      "code": "string",
      "detail": "string",
      "at": "string"
    }
  ]
}

GET /v1/consumers/{consumerId}/receipts

GEThttps://api.codespar.dev/v1/consumers/{consumerId}/receipts

A consumer's agentic receipts

Path parameters

NameTypeRequiredDescription
consumerIdstringyes

Responses

StatusBodyDescription
200objectOK

Response 200

FieldTypeRequiredDescription
receiptsarray of objectyes
Example request
curl -X GET https://api.codespar.dev/v1/consumers/{consumerId}/receipts \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
const res = await fetch("https://api.codespar.dev/v1/consumers/{consumerId}/receipts", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
  },
});

const data = await res.json();
const result = await cs.api.get("/v1/consumers/{consumerId}/receipts", {
  path: {
    consumerId: "csm_0000000000000000"
  }
});
Example response 200
application/json
{
  "receipts": [
    {
      "receipt_id": "receipt_0000000000000000",
      "state": "paid",
      "mandate": {
        "id": "obj_0000000000000000",
        "nonce": "string",
        "scope": "string",
        "currency": "BRL",
        "sig": "string"
      },
      "quote": {},
      "payment": {
        "rail": "string",
        "amount_minor": 1000,
        "amount_authorized": "1000",
        "amount_charged": "1000",
        "amount_refunded": "1000",
        "metering": {
          "basis": "string",
          "units": "string",
          "unit_price": "string"
        },
        "sandbox": true,
        "attempt_id": "attempt_0000000000000000",
        "money_moved": true,
        "at": "string"
      },
      "delivery": {
        "result": "confirmed"
      },
      "chain": "string",
      "receipt_sig": "string",
      "exceptions": [
        {
          "code": "string",
          "detail": "string",
          "at": "string"
        }
      ]
    }
  ]
}
Receipts | CodeSpar