Collect
The 20 operations under collect, as typed calls on the generated REST client.
Available from @codespar/sdk 0.12.0; the version on npm is 0.16.11. Every example on this page is compiled against the installed package when these docs build: a call that does not type-check fails the build.
Every call below is cs.api reaching one operation of the OpenAPI document this page was generated from; the REST client overview explains request, response, the option bag and the errors. The values are placeholders shaped by the document.
import { } from "@codespar/sdk";
const = new ({ : .. });GET /v1/collect/attempts/{attemptId}/artifact
The WhatsApp material of an attempt
const result = await cs.api.get("/v1/collect/attempts/{attemptId}/artifact", {
path: {
attemptId: "attempt_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/attempts/{attemptId}/artifact in the HTTP reference.
POST /v1/collect/attempts/{attemptId}/test-pay
/v1/collect/attempts/{attemptId}/test-paypays the attempt's charge FOR REAL at the Celcoin sandbox
Pay a Test attempt's charge from the shared Test payer (the payer button)
const r = await cs.api.response("post", "/v1/collect/attempts/{attemptId}/test-pay", {
path: {
attemptId: "attempt_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 403),
// each with its own body shape in r.data; nothing here throws on 403.
if (r.ok) {
console.log(r.data);
}This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
The gates that refuse this call, the meaning of each refusal, parameters and every documented response: POST /v1/collect/attempts/{attemptId}/test-pay in the HTTP reference.
GET /v1/collect/links
List this project's Collect links
const result = await cs.api.get("/v1/collect/links");This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/links in the HTTP reference.
POST /v1/collect/links
Create a Collect link with its first draft
const result = await cs.api.post("/v1/collect/links", {
body: {
consumer_id: "csm_0000000000000000",
valid_until: "2026-01-15T12:00:00.000Z",
version: {
title: "Example",
description: "string",
success_message: "string",
items: [
{
name: "Example",
quantity: 0,
unit_amount_minor: 1000
}
],
brand: {
logo_url: "https://example.com/hook",
color: "string",
text_color: "string",
texts: {
header: "string",
footer: "string"
}
},
surfaces: [
"page"
],
due_in_days: 0,
payer_fields: {
contact: "optional",
external_reference: "off"
},
usdc_price: "string"
},
payer: {
name: "Example",
contact: "string",
external_reference: "string",
document: "string",
address: {
publicArea: "string",
number: "string",
neighborhood: "string",
city: "string",
state: "string",
postalCode: "string"
}
}
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/links in the HTTP reference.
GET /v1/collect/links/stats
The project's Collect numbers over the last 30 days
const result = await cs.api.get("/v1/collect/links/stats");This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/links/stats in the HTTP reference.
GET /v1/collect/links/{linkId}
Read a Collect link
const result = await cs.api.get("/v1/collect/links/{linkId}", {
path: {
linkId: "link_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/links/{linkId} in the HTTP reference.
PATCH /v1/collect/links/{linkId}
Change a draft link's validity or receiving consumer
const r = await cs.api.response("patch", "/v1/collect/links/{linkId}", {
path: {
linkId: "link_0000000000000000"
},
body: {
valid_until: "2026-01-15T12:00:00.000Z",
consumer_id: "csm_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 422),
// each with its own body shape in r.data; nothing here throws on 422.
if (r.ok) {
console.log(r.data);
}This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: PATCH /v1/collect/links/{linkId} in the HTTP reference.
POST /v1/collect/links/{linkId}/archive
Archive a Collect link
const result = await cs.api.post("/v1/collect/links/{linkId}/archive", {
path: {
linkId: "link_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/links/{linkId}/archive in the HTTP reference.
GET /v1/collect/links/{linkId}/attempts
List a Collect link's attempts
const result = await cs.api.get("/v1/collect/links/{linkId}/attempts", {
path: {
linkId: "link_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/links/{linkId}/attempts in the HTTP reference.
POST /v1/collect/links/{linkId}/attempts
Issue a Pix attempt for the partner's channel
const r = await cs.api.response("post", "/v1/collect/links/{linkId}/attempts", {
path: {
linkId: "link_0000000000000000"
},
body: {
surface: "whatsapp",
payer: {},
renew: false,
idempotency_key: "string"
}
});
// r.status is one of the documented statuses (200, 422),
// each with its own body shape in r.data; nothing here throws on 422.
if (r.ok) {
console.log(r.data);
}This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/links/{linkId}/attempts in the HTTP reference.
PUT /v1/collect/links/{linkId}/draft
Replace the draft of a Collect link
const result = await cs.api.put("/v1/collect/links/{linkId}/draft", {
path: {
linkId: "link_0000000000000000"
},
body: {
title: "Example",
description: "string",
success_message: "string",
items: [
{
name: "Example",
quantity: 0,
unit_amount_minor: 1000
}
],
brand: {
logo_url: "https://example.com/hook",
color: "string",
text_color: "string",
texts: {
header: "string",
footer: "string"
}
},
surfaces: [
"page"
],
due_in_days: 0,
payer_fields: {
contact: "optional",
external_reference: "off"
},
usdc_price: "string"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: PUT /v1/collect/links/{linkId}/draft in the HTTP reference.
POST /v1/collect/links/{linkId}/pause
Pause a Collect link
const result = await cs.api.post("/v1/collect/links/{linkId}/pause", {
path: {
linkId: "link_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/links/{linkId}/pause in the HTTP reference.
GET /v1/collect/links/{linkId}/payments
List a Collect link's payments
const result = await cs.api.get("/v1/collect/links/{linkId}/payments", {
path: {
linkId: "link_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/links/{linkId}/payments in the HTTP reference.
POST /v1/collect/links/{linkId}/publish
Publish a Collect link
const r = await cs.api.response("post", "/v1/collect/links/{linkId}/publish", {
path: {
linkId: "link_0000000000000000"
},
body: {
confirm_usdc_price: "string"
}
});
// r.status is one of the documented statuses (200, 422),
// each with its own body shape in r.data; nothing here throws on 422.
if (r.ok) {
console.log(r.data);
}This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/links/{linkId}/publish in the HTTP reference.
GET /v1/collect/links/{linkId}/refunds
The refund obligations of a link's exception payments
const result = await cs.api.get("/v1/collect/links/{linkId}/refunds", {
path: {
linkId: "link_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/links/{linkId}/refunds in the HTTP reference.
POST /v1/collect/links/{linkId}/resume
Resume a paused Collect link
const r = await cs.api.response("post", "/v1/collect/links/{linkId}/resume", {
path: {
linkId: "link_0000000000000000"
}
});
// r.status is one of the documented statuses (200, 422),
// each with its own body shape in r.data; nothing here throws on 422.
if (r.ok) {
console.log(r.data);
}This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/links/{linkId}/resume in the HTTP reference.
POST /v1/collect/payments/{paymentId}/honor
Keep a late payment instead of refunding it
const result = await cs.api.post("/v1/collect/payments/{paymentId}/honor", {
path: {
paymentId: "payment_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/payments/{paymentId}/honor in the HTTP reference.
GET /v1/collect/receivers
The consumers that could receive a Collect charge in this project
const result = await cs.api.get("/v1/collect/receivers");This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/receivers in the HTTP reference.
GET /v1/collect/{linkId}
The hosted page's read of a Collect link (public)
const result = await cs.api.get("/v1/collect/{linkId}", {
path: {
linkId: "link_0000000000000000"
}
});This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: GET /v1/collect/{linkId} in the HTTP reference.
POST /v1/collect/{linkId}/attempts
Ask a Collect link for a payable Pix (public)
const r = await cs.api.response("post", "/v1/collect/{linkId}/attempts", {
path: {
linkId: "link_0000000000000000"
},
body: {
page_session: "string",
payer: {},
renew: false
}
});
// r.status is one of the documented statuses (200, 422),
// each with its own body shape in r.data; nothing here throws on 422.
if (r.ok) {
console.log(r.data);
}This path is in the published OpenAPI document but the installed @codespar/sdk does not type it yet, so this one example is not compiled. The call works over HTTP today; cs.api types it after the next release of the package.
Parameters, body and every documented response: POST /v1/collect/{linkId}/attempts in the HTTP reference.