Show examples in:
JavascriptHTTP
Endpoint info
Available examples
Dashboard API > Invoice

Collect all unpaid invoices

Warning: Experimental API

Please note that the Dashboard API is an experimental, prerelease API. This API method is considered unstable, and should be avoided in production environments and automations. Changes may occur at any time without warning.

Body parameters

typestringRequired

Must be exactly "invoice_collection".

attributes.payment_intent_idstringRequired

Returns

Returns an array of resource objects of type invoice.

Examples

POST https://site-api.datocms.com/per-site-pricing-billing-profiles/:field_id_or_api_key/invoices/collect-unpaid HTTP/1.1
Authorization: Bearer YOUR-API-TOKEN
Accept: application/json
X-Api-Version: 3
Content-Type: application/vnd.api+json
{
"data": {
"type": "invoice_collection",
"attributes": {
"payment_intent_id": ""
}
}
}
Terminal window
curl -g 'https://site-api.datocms.com/per-site-pricing-billing-profiles/:field_id_or_api_key/invoices/collect-unpaid' \
-X POST \
-H "Authorization: Bearer YOUR-API-TOKEN" \
-H "Accept: application/json" \
-H "X-Api-Version: 3" \
-H "Content-Type: application/vnd.api+json" \
--data-binary '{"data":{"type":"invoice_collection","attributes":{"payment_intent_id":""}}}'
await fetch(
"https://site-api.datocms.com/per-site-pricing-billing-profiles/:field_id_or_api_key/invoices/collect-unpaid",
{
method: "POST",
headers: {
Authorization: "Bearer YOUR-API-TOKEN",
Accept: "application/json",
"X-Api-Version": "3",
"Content-Type": "application/vnd.api+json",
},
body: JSON.stringify({
data: {
type: "invoice_collection",
attributes: { payment_intent_id: "" },
},
}),
},
);
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: cache-control: max-age=0, private, must-revalidate
X-RateLimit-Limit: 30
X-RateLimit-Remaining: 28
{
"data": [
{
"type": "invoice",
"id": "124",
"attributes": {
"date": "2020-04-21T07:57:11.124Z",
"total": 20,
"amount_due": 20,
"status": "",
"last_failed_transaction": {}
},
"relationships": {
"billing_profile": {
"data": {
"type": "per_site_pricing_billing_profile",
"id": "124"
}
}
}
}
]
}