Developers

ChargePilot API: start with a test key

For the business owner

Connecting your system to ChargePilot means your records and files reach us by themselves. When a customer disputes a charge, the records and files you sent are already with us, so nobody on your team uploads anything for each dispute. Your developer sets this up once, in about an hour, by following the steps below. They can start today with a test key, which lets them build and try every step using made-up customers; nothing sent with a test key is used in a real dispute. When you are ready, we issue your live key, and your developer's code does not change, only the key. To ask for a test key, write to support@chargepilot.ai.

Your system can send ChargePilot the account records that only you hold: when a customer signed up, signed in, used the product, accepted your terms, bought and cancelled. When one of those customers disputes a charge, these dated records are what we put in front of the bank.

If you sell a service. Your system can send ChargePilot the client records that only you hold: when a client accepted your terms, paid, was onboarded, when each meeting was held and each deliverable was sent, and when a client asked to cancel. When one of those clients disputes a charge, these dated records are what we put in front of the bank.

What works today

With a test key. Every call on this page works. Customers and events you send are kept for seven days and never reach a dispute. A file is checked and not kept. The request list holds two made-up requests, so you can build the whole loop.

With a live key. We issue a live key when you are ready; ask us. Customers, events and files you send are stored from that moment. They start being used in your dispute responses when we switch that on for your account, and we tell you when we do. Until then a file is answered held and no request waits on your system.

This page gets you from nothing to a working integration with a test key. Allow about an hour.

What a test key is

  • It works like a live key: the same calls and the same checks. Two answers differ: a file is checked and not kept, and the request list is made up.
  • What you send with it is kept apart, is not used in any dispute response, and is deleted after 7 days.
  • Use made-up customers and events while you build. Do not send real customer records with a test key.
  • Build and test with the test key first. The live key follows. Your code will not change; only the key will.

1. Get the key (2 minutes)

The account owner signs in at https://app.chargepilot.ai, opens Settings, finds API keys and presses Create key on the test row. The key starts with cpm_test_. It is shown once: copy it into your server's secret store. If it is lost, replace it; it cannot be shown again.

Never put the key in a browser, an app, a repository or a ticket. Call the API from your servers only.

2. Check the key (2 minutes)

export CHARGEPILOT_KEY="cpm_test_..."
curl https://api.chargepilot.ai/v1/ping \
  -H "Authorization: Bearer $CHARGEPILOT_KEY"
{"ok": true, "mode": "test", "brand": null, "brands": [{"id": "primary", "name": "Northwind Studio", "no_logs": false}]}

brands lists your brand ids. Every other call must name one. Yours is primary.

3. Tell us who a customer is (5 minutes)

Link your own customer id to the Stripe customer id, the email address, or both. The Stripe customer id is the better of the two: it is how we find the customer when a charge is disputed.

If you sell a service. A customer here is one of your clients: the company you bill.

curl -X POST https://api.chargepilot.ai/v1/customers \
  -H "Authorization: Bearer $CHARGEPILOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"brand": "primary", "customers": [
        {"id": "user_1001", "stripe_customer_id": "cus_TEST123", "email": "test.user@example.com"}
      ]}'
{"ok": true, "mode": "test", "brand": "primary", "accepted": 1, "rejected": []}

Up to 100 customers in one call. Sending a customer again replaces what we hold for that id.

4. Send what the customer did (15 minutes)

A digital business

curl -X POST https://api.chargepilot.ai/v1/events \
  -H "Authorization: Bearer $CHARGEPILOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"brand": "primary", "events": [
        {"id": "evt_1", "customer_id": "user_1001", "type": "signup",
         "occurred_at": "2026-09-01T10:15:00Z", "ip": "203.0.113.7"},
        {"id": "evt_2", "customer_id": "user_1001", "type": "terms_accepted",
         "occurred_at": "2026-09-01T10:15:20Z", "ip": "203.0.113.7", "detail": "Terms of Service version 2026-08"},
        {"id": "evt_3", "customer_id": "user_1001", "type": "login",
         "occurred_at": "2026-11-02T08:40:00Z", "ip": "203.0.113.7", "device": "iPhone 15, iOS 18"},
        {"id": "evt_4", "customer_id": "user_1001", "type": "usage",
         "occurred_at": "2026-11-02T08:44:00Z", "detail": "Generated 12 images"}
      ]}'
{"ok": true, "mode": "test", "brand": "primary", "accepted": 4, "duplicates": [], "rejected": []}

A service business

curl -X POST https://api.chargepilot.ai/v1/events \
  -H "Authorization: Bearer $CHARGEPILOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"brand": "primary", "events": [
        {"id": "evt_1", "customer_id": "client_1001", "type": "terms_accepted",
         "occurred_at": "2026-09-01T15:02:00Z", "ip": "203.0.113.7",
         "detail": "Service agreement version 2026-08, accepted by J. Rivera"},
        {"id": "evt_2", "customer_id": "client_1001", "type": "purchase",
         "occurred_at": "2026-09-01T15:05:00Z", "detail": "Plan: lead generation, monthly, first payment"},
        {"id": "evt_3", "customer_id": "client_1001", "type": "signup",
         "occurred_at": "2026-09-03T17:00:00Z", "detail": "Onboarding call held, campaign brief approved"},
        {"id": "evt_4", "customer_id": "client_1001", "type": "usage",
         "occurred_at": "2026-09-18T16:30:00Z", "detail": "Meeting booked and held: Acme Tools, 30 minutes"},
        {"id": "evt_5", "customer_id": "client_1001", "type": "usage",
         "occurred_at": "2026-09-30T20:00:00Z", "detail": "Deliverable sent: September report, 14 qualified leads"},
        {"id": "evt_6", "customer_id": "client_1001", "type": "cancellation",
         "occurred_at": "2026-10-20T13:10:00Z", "detail": "Client asked to cancel by email"}
      ]}'
{"ok": true, "mode": "test", "brand": "primary", "accepted": 6, "duplicates": [], "rejected": []}
FieldRequiredNotes
idyesYour own id for the event. Sending the same id again is safe: it is counted under duplicates and not stored twice.
customer_idyesThe id you used in step 3. The customer may be sent before or after the event.
typeyesOne of the seven kinds below.
occurred_atyesWhen it happened, ISO-8601 with a time zone, such as 2026-11-02T08:40:00Z. Not in the future, not more than 540 days ago.
ipnoOne IPv4 or IPv6 address.
devicenoOne line, up to 200 characters.
detailnoOne line, up to 200 characters. Plain facts: "Generated 12 images", "Plan: monthly".

Up to 500 events in one call. Each event is answered on its own; one rejected event does not stop the others.

The seven kinds, and when to send each

typeA digital business: send it whenA service business: send it when
signupThe account is created.The client is onboarded: the account is set up and the work begins.
terms_acceptedThe customer accepts your terms. Put the version in detail.The client accepts your agreement or terms. Put the version, and who accepted, in detail.
loginThe customer signs in.The client signs in to your portal or dashboard, if you have one.
usageThe customer uses what they paid for. Say what in detail.The client receives what they paid for: one event for each meeting held and each deliverable sent. Say what in detail.
downloadThe customer downloads a file or an export.The client downloads a report or an export.
purchaseA charge succeeds: a first payment or a renewal. Put the plan in detail.A charge succeeds: a first payment or a renewal. Put the plan in detail.
cancellationThe customer asks to cancel. Send it with the time they asked.The client asks to cancel. Send it with the time they asked, and how, in detail.

Send them as they happen, or in a batch every few minutes. Both work. Events from the last 540 days are accepted, so you can send a client's history as well as what happens from now on.

If your privacy policy says you keep no activity logs, send only signup, login, purchase and cancellation.

5. Read back what we hold (2 minutes)

curl "https://api.chargepilot.ai/v1/customers/user_1001?brand=primary" \
  -H "Authorization: Bearer $CHARGEPILOT_KEY"
{"ok": true, "mode": "test", "brand": "primary", "id": "user_1001",
 "customer": {"stripe_customer_id": "cus_TEST123", "email": "test.user@example.com", "updated_at": "2026-11-19T09:00:00.000Z"},
 "events": {"count": 4, "first_at": "2026-09-01T10:15:00.000Z", "last_at": "2026-11-02T08:44:00.000Z"}}

To erase a customer and all their events, send DELETE to the same address.

6. The same thing in Node

const BASE = "https://api.chargepilot.ai";

async function chargepilot(path, body) {
  const res = await fetch(BASE + path, {
    method: body ? "POST" : "GET",
    headers: {
      "Authorization": `Bearer ${process.env.CHARGEPILOT_KEY}`,
      "Content-Type": "application/json",
    },
    body: body ? JSON.stringify(body) : undefined,
  });
  const answer = await res.json();
  if (!answer.ok) throw new Error(`${answer.error}: ${answer.message}`);
  return answer;
}

await chargepilot("/v1/customers", {
  brand: "primary",
  customers: [{id: "user_1001", stripe_customer_id: "cus_TEST123"}],
});
await chargepilot("/v1/events", {
  brand: "primary",
  events: [{id: "evt_3", customer_id: "user_1001", type: "login",
            occurred_at: new Date().toISOString(), ip: "203.0.113.7"}],
});

7. Send a file

A signed agreement, a statement of work, a report you delivered, a delivery record. Send it for the dispute it answers, or for one of your customers before any dispute exists. A PDF or an image, under 10 MB.

curl -X POST https://api.chargepilot.ai/v1/files \
  -H "Authorization: Bearer $CHARGEPILOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"brand": "primary", "dispute": "du_TEST123",
       "file_name": "service-agreement.pdf", "content_type": "application/pdf",
       "type": "customer_signature", "note": "Signed by the client on Sep 1, 2026",
       "data": "JVBERi0xLjQK..."}'
{"ok": true, "mode": "live", "brand": "primary", "dispute": "du_TEST123", "id": "5f0c…", "status": "attached"}
FieldRequiredNotes
dispute, charge or customer_idexactly oneThe dispute's id, the disputed charge's id, or your own id for the customer.
file_nameyesThe file's name, up to 200 characters.
content_typeyesapplication/pdf, image/png, image/jpeg, image/gif, image/webp, image/heic or image/heif.
typeyesWhat the file is. One of the kinds below.
datayesThe file, as base64.
notenoOne line about the file, up to 280 characters.

What the file is

typeUse it for
customer_signatureA signed agreement, estimate or order.
service_documentationProof the service was performed: a statement of work, a report, a completion record.
shipping_documentationProof of shipment or delivery.
customer_communicationMessages with the customer about the order.
refund_policyYour refund policy as the customer saw it.
cancellation_policyYour cancellation policy as the customer saw it.
receiptA receipt or invoice.
access_activity_logA log showing the customer used the product.
duplicate_charge_documentationProof that two charges were for two different things.
product_descriptionThe product or service page as the customer saw it.

A file for a customer, before any dispute

Send customer_id in place of dispute. We keep the file for 90 days. If that customer's charge is disputed in that time, the file is put on the dispute by itself. Send the customer first with POST /v1/customers, so we know which charges are theirs.

What the answer means

  • "status": "attached": the file is on the dispute, the same as a file uploaded in the app.
  • "status": "held": we have the file. It is attached when file sending is switched on for your account, or, for a customer's file, when a dispute of theirs opens. We keep a held file for 90 days.
  • "status": "checked": a test key. The file passed every check and was not kept.
  • "duplicate": true: we already had this exact file for this dispute. It was not stored again.

When a file is refused

StatuserrorThe message you get
400invalid_requestSay what the file is for with exactly one of: "dispute" (the dispute's id), "charge" (the disputed charge's id) or "customer_id" (your own id for the customer).
400invalid_requestSend "file_name": the file's name, up to 200 characters.
400invalid_request"content_type" must be application/pdf, image/png, image/jpeg, image/gif, image/webp, image/heic or image/heif.
400invalid_request"type" must be one of: … followed by the list of kinds.
400invalid_requestSend "data": the file as base64.
400invalid_request"note" must be text of at most 280 characters.
404dispute_not_foundWe hold no open dispute with that id on this brand.
409several_disputesMore than one dispute matches that charge. Send the dispute's own id as "dispute".
409dispute_closedThat dispute is no longer open for evidence, so the file was not stored.
413file_too_largeThe file must be under 10 MB.
413body_too_largeThe request is too large. A file must be under 10 MB.
422file_refusedThe file is not a PDF or an image we can read, so it was not stored.
422file_refusedThis file cannot be used: … followed by the reason.
422card_number_refusedThis file shows a full card number, so it was not stored. Cover or remove the number and send the file again.
422card_number_refusedWhen the file name or the note holds a card number: the same refusal every other call gives. Nothing is stored.
429dispute_file_limitThis dispute already holds 20 files sent through the API, so the file was not stored.
429daily_limitThis login has reached today's limit of 200 files. The count starts again at midnight UTC.

8. Answer a request

When a dispute needs a document, we ask your system first. Read the open requests, send what you have, and nobody on your team has to do anything. If a request is still waiting after 24 hours, we email your team as we do today. When a deadline is less than three days away we email your team at once and list the request here at the same time.

curl "https://api.chargepilot.ai/v1/requests?brand=primary" \
  -H "Authorization: Bearer $CHARGEPILOT_KEY"
{"ok": true, "mode": "live", "brand": "primary",
 "requests": [
  {"id": "rq_du_TEST123", "dispute": "du_TEST123", "charge": "ch_TEST456", "order": "1042",
   "customer_id": "cus_889", "email": "pat@example.test",
   "amount": 12900, "currency": "usd",
   "asked_at": "2026-12-01T14:05:00Z", "respond_by": "2026-12-09T23:59:59Z",
   "documents": [
    {"key": "cancellation_policy", "what": "Your cancellation policy as the customer saw it",
     "send_as": ["cancellation_policy"], "most_important": true, "status": "waiting"},
    {"key": "access_log", "what": "A record showing the customer used the product",
     "send_as": ["access_activity_log", "events"], "most_important": false, "status": "received"}
   ]}
 ],
 "next": null}
FieldNotes
idThe request's id. It stays the same while the dispute is open.
dispute, charge, orderThe dispute, the disputed charge and your order number when we hold one.
customer_idYour own customer id, when you have sent us that customer.
emailThe customer's email on the charge.
amount, currencyThe disputed amount in the currency's smallest unit.
respond_bySend before this time. After it, nothing more can be added.
documentsWhat is asked. One row per document.
nextWhen there are more than 100 requests, pass this value as ?after= to read the rest.

Each document

FieldNotes
whatThe document, in plain words.
send_asHow to send it. A file type for POST /v1/files, or events when records sent to POST /v1/events answer it.
most_importanttrue for the document that matters most for this dispute. Send it first.
statuswaiting: we do not have it. received: we have it. not_used: a file arrived and could not be used for this document. Send the right one.

How to answer

Send the file for the dispute, with one of the send_as types. There is nothing else to call.

curl -X POST https://api.chargepilot.ai/v1/files \
  -H "Authorization: Bearer $CHARGEPILOT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"brand": "primary", "dispute": "du_TEST123",
       "file_name": "cancellation-policy.pdf", "content_type": "application/pdf",
       "type": "cancellation_policy", "data": "JVBERi0xLjQK..."}'

A request leaves the list when nothing in it is waiting, or when the dispute closes. Read the list every 15 minutes, or more often. Sending the same file twice is safe.

Read one request

curl "https://api.chargepilot.ai/v1/requests/rq_du_TEST123?brand=primary" \
  -H "Authorization: Bearer $CHARGEPILOT_KEY"

It answers for 30 days after the request left the list, with each document's last status.

With a test key

The list holds two made-up requests so you can build against it. A file you send for one of them is checked and not kept, and its document shows received for the next hour.

When a call is refused

StatuserrorWhat to do
400brand_requiredAdd ?brand=. GET /v1/ping lists your brands.
400invalid_request"after" must be the "next" value of the previous answer.
404request_not_foundWe hold no request with that id on this brand. Check the id and the brand.
429rate_limitedWait a minute. Reading the list every 15 minutes is enough.

Rules

  • No card numbers, ever. If any value in a call looks like a card number, the whole call is refused and nothing is stored. Do not send security codes or passwords either.
  • Sending twice is safe. Events are matched on your event id. For a whole call, add an Idempotency-Key header with any unique text; repeating the call with the same key returns the first answer.
  • Limits. 120 calls a minute. 256 KB a call, or 10 MB for a file. 50,000 events, 10,000 customers and 200 files a day. 20 files a dispute.
  • Only the fields on this page. A field we do not know is refused, with its name in the answer.

When a call is refused

Every refusal is JSON with "ok": false, an error code and a message that says what to change.

One event or one customer that cannot be accepted does not refuse the whole call. The call still answers 200, and that item is listed under rejected with its own error and message (for example unknown_field for a field that is not on this page, or occurred_at_in_future). Check rejected on every answer.

StatuserrorWhat to do
401missing_authorization, malformed_credential, invalid_keyCheck the Authorization: Bearer header and the key. A replaced or revoked key stops at once.
400brand_required, unknown_brandAdd "brand": "primary". The answer lists your brand ids.
400unknown_field, invalid_requestSend only the fields on this page, as a JSON object.
403live_not_enabledA live key is not switched on for this account yet. Write to us.
422card_number_refusedRemove the value the message names. Nothing from the call was stored.
429rate_limited, daily_limitWait the number of seconds in the Retry-After header, or until the next day (UTC).
500internal_errorSend the call again.

Questions

Write to support@chargepilot.ai with the time of the call and the error code. Never send us a key.

ChargePilot Support