Skip to main content

Consumers

Generated HTTP reference for the 5 operations the published OpenAPI document describes under consumers.

3 min read
View MarkdownEdit on GitHub

Consumers

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.

GET /v1/consumers

GEThttps://api.codespar.dev/v1/consumers

List titulars

Query parameters

NameTypeRequiredDescription
limitintegerno
verified"true" | "false"no

Responses

StatusBodyDescription
200objectOK
400objectBad Request — the body or query did not match the schema.

Response 200

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

const data = await res.json();
Example response 200
application/json
{
  "consumers": [
    {
      "id": "obj_0000000000000000",
      "metadata": {},
      "status": "unverified",
      "created_at": "string"
    }
  ]
}

POST /v1/consumers

POSThttps://api.codespar.dev/v1/consumers

Create the titular, without a document

Request body

FieldTypeRequiredDescription
display_namestringno
metadataobjectno

Responses

StatusBodyDescription
201objectOK
400objectBad Request — the body or query did not match the schema.

Response 201

FieldTypeRequiredDescription
created_atstringyes
display_namestring,nullyes
documentstring,nullyes
document_sourcestring,nullyes
document_verified_atstring,nullyes
idstringyes
metadataobjectyes
person_typestring,nullyes
status"unverified" | "verified"yes
tax_typestring,nullyes
Example request
curl -X POST https://api.codespar.dev/v1/consumers \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "display_name": "Example",
       "metadata": {}
     }'
const res = await fetch("https://api.codespar.dev/v1/consumers", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "display_name": "Example",
    "metadata": {}
  }),
});

const data = await res.json();
Example response 201
application/json
{
  "id": "obj_0000000000000000",
  "metadata": {},
  "status": "unverified",
  "created_at": "string"
}

GET /v1/consumers/{id}

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

Read one titular, with the ids of what hangs off it

Responses

StatusBodyDescription
200objectOK
404objectNot Found

Response 200

FieldTypeRequiredDescription
created_atstringyes
display_namestring,nullyes
documentstring,nullyes
document_sourcestring,nullyes
document_verified_atstring,nullyes
idstringyes
metadataobjectyes
person_typestring,nullyes
status"unverified" | "verified"yes
tax_typestring,nullyes
Example request
curl -X GET https://api.codespar.dev/v1/consumers/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY"
const res = await fetch("https://api.codespar.dev/v1/consumers/{id}", {
  method: "GET",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
  },
});

const data = await res.json();
Example response 200
application/json
{
  "id": "obj_0000000000000000",
  "metadata": {},
  "status": "unverified",
  "created_at": "string"
}

PATCH /v1/consumers/{id}

PATCHhttps://api.codespar.dev/v1/consumers/{id}

Update the mutable fields of a titular

Request body

FieldTypeRequiredDescription
display_namestring,nullno
metadataobjectno
tax_type"PJ" | "MEI" | "ME" | "PF"no

Responses

StatusBodyDescription
200objectOK
400objectBad Request — the body or query did not match the schema.
404objectNot Found

Response 200

FieldTypeRequiredDescription
created_atstringyes
display_namestring,nullyes
documentstring,nullyes
document_sourcestring,nullyes
document_verified_atstring,nullyes
idstringyes
metadataobjectyes
person_typestring,nullyes
status"unverified" | "verified"yes
tax_typestring,nullyes
Example request
curl -X PATCH https://api.codespar.dev/v1/consumers/{id} \
  -H "Authorization: Bearer $CODESPAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "metadata": {},
       "tax_type": "PJ"
     }'
const res = await fetch("https://api.codespar.dev/v1/consumers/{id}", {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.CODESPAR_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "metadata": {},
    "tax_type": "PJ"
  }),
});

const data = await res.json();
Example response 200
application/json
{
  "id": "obj_0000000000000000",
  "metadata": {},
  "status": "unverified",
  "created_at": "string"
}

GET /v1/consumers/{id}/wallet

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

The consumer's unified wallet, rolled up per currency

Path parameters

NameTypeRequiredDescription
idstringyes

Responses

StatusBodyDescription
200objectOK

Response 200

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

const data = await res.json();
Example response 200
application/json
{
  "consumer_id": "csm_0000000000000000",
  "currencies": [
    {
      "currency": "BRL",
      "authorized_minor": 1,
      "spent_minor": 1,
      "available_minor": 1,
      "funding_source_ids": [
        "string"
      ],
      "mandate_ids": [
        "string"
      ]
    }
  ]
}
Consumers | CodeSpar