Collect and refund by direct debit
Two singular sub-resources of a sales invoice let you trigger and follow a SEPA direct debit at GoCardless: gocardless_payment for the collection, gocardless_refund for its refund. Each is opened with a POST and read back with a GET on the same address. They are singular because the GET always returns the most recent one, never a list.
These calls move real money. Nothing is simulated. Both POSTs require an Idempotency-Key header, and it is that header which guarantees a replayed call neither debits nor refunds a second time.
The two operations, and when to use each
| Operation | Use when | Scopes |
|---|---|---|
POST /api/v1/invoices/{invoice_id}/gocardless_payment | The invoice is issued and you want to debit the outstanding balance from the customer's account. | write |
GET /api/v1/invoices/{invoice_id}/gocardless_payment | You are following that debit: mandate authorization, submission, collection, failure. | read |
POST /api/v1/invoices/{invoice_id}/gocardless_refund | The debit has been collected and you want to return the whole amount to the customer, with the matching credit note. | write |
GET /api/v1/invoices/{invoice_id}/gocardless_refund | You are following the refund and waiting for the credit note's number. | read |
Collection is a recovery operation: you open it on an invoice the customer has not paid yet. Refunding is a correction operation: it only opens on a collection whose funds have actually been taken, it always covers that collection in full, and it gives rise to a credit note, which a refund renewed after the funds came back reuses instead of issuing a second one. There is no partial refund.
The two prerequisites
Both prerequisites are checked on all four calls, the GETs included, and they do not report themselves the same way.
The gocardless_payment feature: 403
The gocardless_payment feature must be enabled for the tenant that owns the invoice. When it is not, the answer is a 403 carrying the standard error body, with no field naming the feature.
The company's offer must cover sales: 404
The company issuing the invoice must hold an offer covering the sales capability. When it does not, the invoice is simply out of the request's reach and the answer is a 404, indistinguishable from an invoice that does not exist. The same 404 covers an invoice belonging to another workspace and a purchase invoice.
One exception: a self-billed invoice received over the e-invoicing network, of which your company is the seller, stays readable whatever the offer, including through GET /api/v1/invoices/{invoice_id}/gocardless_payment. Opening a collection on it (POST /api/v1/invoices/{invoice_id}/gocardless_payment) is however refused with 422 operation_failed, without details, with the message Votre offre n'inclut pas la facturation de vente. Contactez votre cabinet comptable pour mettre à niveau votre offre. That refusal is decided before any call to GoCardless and does not consume the Idempotency-Key.
Order matters: the invoice is resolved before the feature is evaluated. An out-of-reach ID therefore returns 404 even when the feature is disabled, and the 403 is only visible on an invoice you actually reach.
The Idempotency-Key header
Both POSTs require it. A POST that carries none is refused with a 422 whose code is validation_failed, and it is details.idempotency_key that names what is missing. The GETs never carry one.
{
"error": "unprocessable_entity",
"code": "validation_failed",
"message": "La validation a échoué",
"details": {
"idempotency_key": ["est requis"]
}
}
Pick a value unique to each operation - a UUID will do - and keep it: it is what lets you retry without debiting twice. This refusal does not consume the key, since nothing was attempted.
Replay
The same key with the same body and the same query string replays the stored response unchanged, with the Idempotency-Replayed: true response header. The call that receives that header opened no collection and requested no refund; the one that actually acted does not carry it. That is how you tell them apart.
If you rebuild the body instead of resending the original bytes, every number must keep its form, integer or decimal, and its exact value from the first time. Another spelling of the same decimal number (1.5 and 1.50, or 150.00, 150.0 and 1.5e2) replays. An integer and a decimal number make two different bodies, even at equal value (150 and 150.00), as do two numbers that differ only beyond a double's precision (0.1 and 0.10000000000000001): the second call receives a 409 idempotency_key_reuse. This rule holds for a key stored since it took effect. A key stored just before, and still held for its 24 hours, is compared as it was then, every number read as a double: two numbers the double confuses (0.1 and 0.10000000000000001) replay the stored response there, while an integer and a decimal number (150 and 150.00) remain two different bodies.
While this rule takes effect, a retry can also receive a 409 idempotency_key_reuse even though it resends the first call's body byte for byte: this happens when the first call was handled under the new rule and the retry still under the old one. That 409 therefore proves neither that the first call did nothing nor that it acted. Retry with the same key and the same request: a retry handled under the new rule replays the first call's stored response, if that call succeeded. Send a fresh key only by following the procedure in Reading a first call's outcome.
Only 2xx responses are stored: a 4xx refusal never becomes a key's replayed response.
The key is held for 24 hours. After that it is reusable, and a POST carrying it starts a fresh operation.
The JSON body of this POST is capped at 4 MiB (4,194,304 bytes), with or without a key, whatever the token: past that, it gets a 413 with no body before any processing, nothing is attempted, the key is not reserved and the request is not counted against the 300 requests per minute limit (API conventions).
The three 409s
code | What it says | What to do |
|---|---|---|
idempotency_key_reuse | The same Idempotency-Key has already served a different body or query string - or, while the rule above takes effect, the same body. | To replay the stored response, resend the original body and query string with this key; for the same body, retry with the same key. Send a fresh key only by following Reading a first call's outcome: a fresh key on an operation that already ran collects or refunds twice. |
idempotency_key_consumed | An earlier call carrying this key finished and was refused after it may have reached GoCardless; the key stays held for its 24 hours. Nothing is running, and nothing will complete. | Do not send this key again: it will replay nothing during its 24 hours. Send a new order under a fresh key only by following Reading a first call's outcome. |
idempotency_request_in_progress | An earlier call carrying this key is still running, or ended with its outcome unknown. | Retry later with the same key and the same request, at a spaced interval: if the first call succeeds, the retry replays its response. It is never an invitation to loop: if the retry still answers this code, follow Reading a first call's outcome. |
{
"error": "conflict",
"code": "idempotency_key_consumed",
"message": "Une requête antérieure portant cette clé Idempotency-Key s'est terminée, a effectué un traitement hors de cette plateforme, puis a été refusée. Rien n'a été écrit par cet appel et cette clé n'est pas rejouable : vérifiez le résultat de la première requête, puis envoyez une nouvelle clé si le traitement reste à faire"
}
None of the three opened a collection or requested a refund.
Reading a first call's outcome
GET /api/v1/invoices/{invoice_id}/gocardless_payment and GET /api/v1/invoices/{invoice_id}/gocardless_refund do not look a call up by its Idempotency-Key: each returns the invoice's most recent record, whichever call created it. It is a reconciliation hint, not proof:
- a record whose
created_atpredates your first call is not that call's; - a collection does not appear while its call is running, and if the call to GoCardless fails or times out, it is rolled back locally, including when GoCardless did receive the request: the
GETthen answers404, or shows an older collection; - a refund request is recorded as
requestedbefore it is submitted to GoCardless, and stays recorded when the submission's outcome is unknown; it is withdrawn only on a definitive refusal from GoCardless, or by a later request that establishes that GoCardless does not hold it (step 3 below).
The GET, and the created_at it reports, are therefore only a hint: a 404, or a record older than your call, does not prove that nothing left, and a record created after your first call began does not prove it came from that call. Only the original key's replayed response (header Idempotency-Replayed: true), or a GET reporting the id that a response to that first call returned to you, confirms the outcome. After a call whose response you did not receive, or that answered idempotency_request_in_progress, follow therefore a single procedure:
- During the key's 24-hour retention window, counted at the latest from your first send, retry with the original key and the original request, at a spaced interval. If the first call succeeded, the retry replays its response; if it was refused without sending anything to GoCardless, the key was released and the retry runs normally.
- Stop sending the original key as soon as it answers
idempotency_key_consumedor still answersidempotency_request_in_progress, and in any case once those 24 hours have passed: past that window, the first call carrying it clears its expired reservation and runs the operation as if it were the first. - Then read the invoice's state through the operation's
GET. If it reports theidthat a response to the first call returned to you, the operation took place. On a refund, a new request under a fresh key does not refund twice: as long as arequested,createdorpaidrefund exists on the collection, it is refused withalready_refunded, which releases its key. A refund stillrequestedis a request whose outcome at GoCardless was never observed, and the next request settles it, by asking GoCardless before sending anything. Once 10 minutes have passed since that record'screated_at, send the same request under a fresh key: if GoCardless holds the refund, the record moves tocreatedand the request is refused withalready_refunded; if it does not, the record is withdrawn and the request submits the refund. Before those 10 minutes, or if GoCardless does not answer, the record is kept and the request is refused withalready_refunded: retry later. On a collection, theGETcannot establish it: it proves a debit, never its absence. Send no fresh key until the debit's absence is confirmed outside this API, through the GoCardless dashboard or its support: a fresh key, or a retry after the customer's mandate changed, can debit the buyer twice.
Which refusals release the key, and which hold it
This is the part to read before writing your retry logic, and the two endpoints do not decide it the same way.
On the refund, the key follows the split of the three details.reason_code groups described below. Eligibility refusals (group 1) and no_connection (group 2) are decided before any call to GoCardless: they release the key, and reusing it once the cause is fixed is served normally. connector_error and unavailable (group 3) are raised after the call, and the outcome is not established: they hold the key for the full 24 hours, so a further call carrying it answers 409 idempotency_key_consumed.
On the collection, every operation_failed refusal holds the key, with a single exception: the refusal of a received self-billed invoice while the company's offer does not include sales invoicing, decided before any call to GoCardless, does not consume it (The company's offer must cover sales: 404). Any other refusal arrives with a bare message, with no code to branch on, so the platform cannot tell a refusal decided before the request reached GoCardless from a failure that happened after it. It fails closed, deliberately: of the two ways to be wrong, holding a key for nothing costs a key, whereas releasing it too early debits the same buyer twice.
The practical instruction follows: on the collection, the GET proves a debit, never its absence. If it reports a collection created after your call began, nothing says it is yours: it may come from another integration or a Scribee user. If it answers 404, or shows only a collection older than your call, a debit may still be open at GoCardless: when GoCardless received the request but its answer was lost, nothing is recorded here. Retry only under the same key with the same request, and send a fresh key only once the debit's absence is confirmed outside this API, following the procedure in Reading a first call's outcome.
Open a collection
POST /api/v1/invoices/{invoice_id}/gocardless_payment opens a SEPA direct debit for the invoice's whole outstanding amount, through the company's connected GoCardless account. The amount is never supplied by the caller.
If the customer has already authorized a mandate, the debit goes out directly. Otherwise an authorization request is emailed to the named contact and the collection is returned in pending_authorization; the debit itself follows once the mandate is authorized.
curl -X POST https://app.scribee.tech/api/v1/invoices/YOUR_INVOICE_ID/gocardless_payment \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Idempotency-Key: 4f1c2a6e-0d1b-4f2a-9a11-8d0e2c3b7a55" \
-H "Content-Type: application/json" \
-d '{
"collection": {
"contact_id": 42
}
}'
The response is a 201 Created:
{
"data": {
"id": 314,
"status": "pending_authorization",
"amount": 1200.0,
"currency_code": "EUR",
"failure_reason": null,
"failure_description": null,
"created_at": "2025-03-04T09:12:00Z",
"updated_at": "2025-03-04T09:12:00Z"
}
}
The body is optional
A POST with no body is valid, and it is the common case: with no contact named, the collection relies on the mandate the customer has already authorized. The body is only needed for the very first authorization, the one that needs a recipient.
When you do send it, only two fields are accepted under the collection key:
contact_idnames the customer contact the authorization request is sent to. That contact must already exist on the invoice's customer record: this endpoint does not create a contact, and it does not accept a contact described inline. Create it through the directory endpoints first (see Customers and suppliers), then name it here by itsid.emailfills in an address on that contact when it carries none. If the contact already has one, the value you send is ignored - it does not replace it.
contact_id is resolved among the contacts of the invoice's customer, and nobody else's: a contact ID belonging to another party is refused.
The statuses of a collection
status is GoCardless's own vocabulary, passed through as is, and the reference lists its nine values. Several things follow for your code.
confirmed and paid_out are the only two states a refund can act on: the first says the funds have been taken from the customer's account and are held by GoCardless, the second that they have since reached the merchant's account.
not_required is not a failure. The mandate was indeed authorized, but the invoice was settled in the meantime, so no debit was ever created at the provider. It is a terminal state: reopening a collection from there would lead nowhere.
charged_back says the funds were paid out, then taken back by the customer's bank. Scribee then cancels the payment that payout had recorded: it disappears from the invoice's list of payments, a 212 event with a negative amount is written in the lifecycle, with the reason the direct debit was taken back as its reason, and the invoice is owed again - remaining_amount goes back up by the amount taken back, while lifecycle_state stays collected (Record payments). It is a terminal state: a payout announced later for this direct debit records no payment any more, and nothing prevents you from opening a new collection.
A direct debit whose payout fails late, after it was paid out, is cancelled the same way, but returns to failed rather than charged_back.
If the customer's bank later withdraws its chargeback, nothing changes on the API side: status stays charged_back, no payment is recorded again, and the invoice stays owed until a payment settles it.
On a failed as on a charged_back, failure_reason and failure_description carry the reason returned by GoCardless - the provider's code and its readable form.
Refusals
A collection refusal is a 422 whose code is always operation_failed. That refusal carries no details: unlike the refund, there is nothing stable to branch on, and it is message that names the cause - no connected GoCardless account, no customer on the invoice, a collection already in flight, nothing left to collect, no contact to send the authorization to, or a currency GoCardless does not accept (only AUD, CAD, DKK, EUR, GBP, NZD, SEK and USD can be collected).
{
"error": "unprocessable_entity",
"code": "operation_failed",
"message": "Cette entreprise n'a pas de compte GoCardless connecté"
}
This refusal holds the key. With no code to branch on, the platform cannot establish that nothing left for GoCardless, so it keeps the key for the full 24 hours: a further call carrying it answers 409 idempotency_key_consumed. That 409 is final - the first call has finished, and waiting will change nothing. Do not send this key again. A GET that reports no collection from the first call does not prove that nothing left: send a new order under a fresh key only once the debit's absence is confirmed outside this API (Reading a first call's outcome).
The invoice's lifecycle status is checked upstream, and its refusal is not a 422: an invoice outside the states where a payment can be recorded (200 Deposited, 202 Received, 203 Made available, 204 Taken in charge, 205 Approved, 207 Disputed, 211 Payment sent, 212 Collected) answers 403. See The invoice lifecycle.
Read the collection
GET /api/v1/invoices/{invoice_id}/gocardless_payment returns the invoice's most recent collection, with the same fields as the creation. The read scope is enough.
curl https://app.scribee.tech/api/v1/invoices/YOUR_INVOICE_ID/gocardless_payment \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
As long as no collection has been opened, this call answers 404. That is the normal answer before the first POST, not an error about the invoice. The GET stays reachable whatever the invoice's status, including after it has left the states where a collection could be opened - which is exactly when you want to follow the one already running.
Refund
POST /api/v1/invoices/{invoice_id}/gocardless_refund refunds the invoice's settled collection in full and issues the matching credit note, at the moment described below. The call takes no request body: the amount is the collection's own.
This call returns money to the customer and it is irreversible: there is no endpoint to cancel an accepted refund. A second POST carrying the same Idempotency-Key replays the first one's response without refunding again; carrying a fresh key, it is refused with already_refunded for as long as a refund is alive on the collection. So check the collection through its GET before refunding.
curl -X POST https://app.scribee.tech/api/v1/invoices/YOUR_INVOICE_ID/gocardless_refund \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Idempotency-Key: 9b2e1f04-7c3a-4d15-b8e6-2a5c7d9e1f30"
{
"data": {
"id": 57,
"status": "requested",
"amount": 1200.0,
"currency_code": "EUR",
"settled_at": null,
"credit_note_id": null,
"credit_note_number": null,
"created_at": "2025-03-20T10:30:00Z",
"updated_at": "2025-03-20T10:30:00Z"
}
}
A 201 means accepted, not arrived
A 201 means the refund was accepted by GoCardless, not that the money has reached the customer. Poll the GET on that same address for what follows.
status and settled_at are two independent axes
Do not read one for the other. settled_at carries the date GoCardless reported the refund as settled; status carries the refund's state. The two move separately, and a settled refund can still fail: GoCardless treats its failed and refund_settled events as unrelated. A client reading only settled_at would report as received by the buyer an amount that has in fact come back to the merchant.
status | Meaning |
|---|---|
requested | A local claim, recorded before the refund was submitted. It exists even when the submission's outcome could not be observed. |
created | GoCardless created the refund. |
paid | GoCardless paid the refund. |
failed | The refund failed, and the funds come back to you. |
funds_returned | The funds have come back. |
The credit note
credit_note_id and credit_note_number are null until the credit note is issued, and always together. The credit note is issued once GoCardless has reported the refund both paid and settled: whichever of those two events arrives second triggers it, in either order. If that settlement never arrives, a daily recovery run issues it once 45 days have passed since the refund was paid. A refund whose funds come back before issuance gets none. A refund just requested therefore legitimately answers with neither. Once filled in, credit_note_id is the ID of an invoice you read back with GET /api/v1/invoices/{id}, and credit_note_number is the number it carries (BT-1). Its type_code is retainer_credit_note (retainer credit note, BT-3 503) when the refunded invoice is a retainer invoice (retainer_invoice, 386), and credit_note (381) in every other case.
On that credit note, issue_date (BT-2) is the day it was issued, and due_date (BT-9) the day the refund was paid to the customer, never the day it settled. Since the credit note is issued after that payment, due_date can precede issue_date.
When the funds come back after the credit note
A refund can move to failed or funds_returned after its credit note was issued, including after it settled. The credit note then stays as issued: Scribee does not cancel it and issues no counter-document.
A new POST on the same invoice is then no longer refused with already_refunded, since no refund is alive on the collection any more. That new refund does not lead to a second credit note: it is attached to the one already issued, and carries credit_note_id and credit_note_number filled in from creation, 201 response included.
Read the refund
GET /api/v1/invoices/{invoice_id}/gocardless_refund returns the most recent refund requested on the invoice's collection. As long as no refund has been requested, it answers 404.
curl https://app.scribee.tech/api/v1/invoices/YOUR_INVOICE_ID/gocardless_refund \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
The details.reason_code vocabulary
On a refund refusal, code is always operation_failed: the API's published error vocabulary holds no GoCardless-specific value, and it is frozen. The stable discriminator therefore travels in details.reason_code, as a single-element array - the same shape as the other details entries. Branch on reason_code: it is never translated nor reworded, whereas message is localized.
{
"error": "unprocessable_entity",
"code": "operation_failed",
"message": "GoCardless refuse un remboursement dans les 7 jours suivant l'encaissement. Ce paiement pourra être remboursé à partir du 11/03/2025.",
"details": {
"reason_code": ["safer_refund_period"]
}
}
The values fall into three groups, and it is the group that decides whether you may retry. Never re-fire a POST on the strength of the 422 alone: read which group the value you got belongs to first.
Group 1 - eligibility: nothing was sent
These fourteen conditions are decided before any network call. No refund exists on the GoCardless side, and retrying once the cause is fixed is safe. They are evaluated in the table's order, and only one is returned: the first one met.
These refusals release the Idempotency-Key: the same key, replayed once the cause is fixed, is served normally.
reason_code | What it says | What to do |
|---|---|---|
no_refundable_payment | The invoice carries no collection whose funds have been taken. | Wait for the collection to reach confirmed or paid_out. |
payment_required | The eligibility check was reached with no collection to examine at all. This endpoint answers no_refundable_payment for that situation. | Treat the two identically. |
payment_not_settled | The collection picked is not in a settled state. | Same wait. |
multiple_settled_collections | The invoice carries several settled collections; refunding one would leave the others uncredited while the credit note would cancel the whole invoice. | Reconcile those collections before refunding. |
payment_currency_mismatch | The collection was taken in a currency other than the invoice's; the credit note would be issued in a different currency from the one collected. | Reconcile the two currencies. |
payment_amount_mismatch | The collection does not match the invoice's total including tax. Only a total refund is supported, and the equality is strict: an over-collection is refused too. | Reconcile the collected amount. |
safer_refund_period | GoCardless refuses a refund within 7 calendar days of the collection. | Retry after the date message carries. |
already_refunded | A refund is already under way on this collection. | Read it through the GET. |
document_not_referenceable | The credit note must quote the number of the invoice it cancels, and this invoice carries none issued by Scribee. Or the invoice was drawn up by your customer (type_code in self_billed_*: BT-3 389, 500, 501, 471, 473, 261 and 502): its credit note is not yours to issue. | No refund is possible this way. |
sales_capability_not_allowed | The company's offer does not allow issuing invoices, so no credit note can be produced. | Change offer. |
no_invoice_pattern | The company has no invoice numbering pattern, so the credit note cannot be numbered. | Set it in the invoicing settings. |
missing_legal_mentions | The credit note would be missing mandatory legal mentions. | See below. |
refunds_not_enabled | Refunds are not enabled on the GoCardless account. | Enable them from the GoCardless dashboard. |
creditor_status_unavailable | GoCardless did not answer and the account's permission to refund could not be verified. | Retry later. |
The missing_legal_mentions case
It is the only reason_code whose refusal is repairable field by field, and the other details keys name the company invoicing settings to fill in before retrying. Each key is a setting's name, and its value the reason:
{
"error": "unprocessable_entity",
"code": "operation_failed",
"message": "L'avoir serait dépourvu de mentions légales obligatoires (pénalités de retard et frais de recouvrement). Renseignez-les dans les paramètres de facturation de l'entreprise, puis réessayez.",
"details": {
"reason_code": ["missing_legal_mentions"],
"late_payment_disclaimer": ["Cette mention légale obligatoire est absente des paramètres de facturation de l'entreprise."],
"recovery_costs_disclaimer": ["Cette mention légale obligatoire est absente des paramètres de facturation de l'entreprise."]
}
}
The three possible keys are late_payment_disclaimer (late-payment penalties), recovery_costs_disclaimer (recovery costs) and cash_discount_disclaimer (early-payment discount). Only the missing ones appear. These settings are filled in from the company's invoicing settings, or through the API under the same field names with PATCH /api/v1/companies/{id} (Companies and establishments).
Group 2 - no_connection: nothing was sent either
no_connection says the company's GoCardless account is not connected, or that its authorization has been revoked. The condition is decided before any network call, like those of group 1: nothing was sent. It releases the key too. Reconnect the account, then retry.
review_workspace also belongs to this group: the invoice belongs to the Scribee store-review workspace, an internal workspace that sends nothing to GoCardless; a partner integration does not meet it. The refusal is returned before any check and releases the key, but a retry will not succeed.
Group 3 - connector_error and unavailable: sent, outcome not established
These two values are raised after the refund was submitted. connector_error says GoCardless answered with an error, message carrying the detail the provider returned; unavailable says GoCardless could not be reached, or did not answer in time.
In both cases, GoCardless may hold the refund. Do not blind-retry the POST: GET this same path first, and treat any refund it reports as the one you asked for. The request is in fact recorded locally as requested before submission, so a second POST would answer already_refunded anyway for as long as it is alive.
These two values hold the key for the full 24 hours: a further call carrying it answers 409 idempotency_key_consumed, which is the signal to go and read the GET rather than to send the refund again. That 409 is final: do not send this key again. A refund the GET reports as created or paid is the one you asked for. A refund still requested is resumed under a fresh key, which asks GoCardless before sending anything, following step 3 of Reading a first call's outcome.
What the API does not expose
No GoCardless resource identifier is published. Neither the debit's, nor the mandate's, nor the refund's identifier at the provider appears in the responses: the only identifiers returned, id and credit_note_id, are Scribee's own. The status vocabulary is indeed GoCardless's - that is the fact you asked for - but the key the provider indexes it by is not. So do not write an integration that would reconcile these responses against your own GoCardless dashboard by identifier.
The published fields are exactly those of the samples above: id, status, amount, currency_code, failure_reason, failure_description, created_at and updated_at for a collection; id, status, amount, currency_code, settled_at, credit_note_id, credit_note_number, created_at and updated_at for a refund.
Errors and edge cases
401 Unauthorized
Token missing, expired, or invalid. Request a new token from /oauth/token (Authentication).
403 Forbidden
Several distinct causes share this body: the token does not carry the required scope, the gocardless_payment feature is not enabled for the invoice's workspace, the token's application may not write to this invoice, or - when opening a collection - the invoice's lifecycle state no longer allows a payment to be recorded against it. On a POST, nothing was sent to GoCardless.
{
"error": "forbidden",
"message": "Vous n'êtes pas autorisé à effectuer cette action"
}
Nothing in the response tells these apart. Check your scopes first: the GETs require read, the POSTs require write.
409 Conflict
The Idempotency-Key you sent cannot serve this request: idempotency_key_reuse when it has already served a different body or query string (or, while the number comparison rule takes effect, the same body), idempotency_key_consumed when an earlier call carrying it ended in a refusal after it may have reached GoCardless, idempotency_request_in_progress when an earlier call carrying it is still running or ended with its outcome unknown. No collection was opened and no refund requested by this call. The three are not retried the same way: see above.
404 Not Found
The invoice does not exist, it belongs to a workspace outside your application's reach, it is not a sales invoice, the company's offer does not cover sales invoicing, or - on a GET - no collection and no refund has been opened yet.
{
"error": "not_found",
"message": "La ressource demandée est introuvable"
}
To tell these causes apart, read the invoice itself with GET /api/v1/invoices/{id}: if it answers, the 404 points at the sub-resource rather than the invoice - no collection, or no refund, has been opened yet.
Related pages
- Record payments - a settled collection records a payment, which you read back there
- The invoice lifecycle - the statuses that allow a collection to be opened
- Customers and suppliers - create the contact
contact_idnames - API reference: open a collection
- API reference: read the collection
- API reference: refund
- API reference: read the refund