Docs
Integration prompt for your AI
A ready prompt and the OpenAPI spec, so your coding assistant writes the integration.
Coding assistants write a good integration when they know the contract. Copy the prompt below into yours, add a sentence about your app, and it has what it needs: the endpoints, authentication, how to read a result, and how to handle errors and limits.
OpenAPI spec
The full contract is in our OpenAPI 3.1 file. It is the same file these docs are built from, so it always matches the live API. Point your assistant or your client generator at it:
https://descriptorapi.com/openapi.yamlIntegration prompt
Replace the last line with what you are building.
You are integrating DescriptorAPI, which turns raw card transaction descriptors (the text a bank statement shows, e.g. "POS 4521 CAREEM*RIDE DXB AE") into the merchant behind them.
Source of truth: the OpenAPI 3.1 spec at https://descriptorapi.com/openapi.yaml. Read it before writing code and follow it over anything below.
Basics
- Base URL: https://api.descriptorapi.com
- Auth: send "Authorization: Bearer $DESCRIPTORAPI_KEY" (or "X-API-Key"). Keys start with dk_live_. Read the key from an environment variable and call the API only from the server, never from a browser or mobile app.
- JSON in, JSON out. Every response has a request_id; log it.
Endpoints
- POST /v1/enrich: Enrich one descriptor
- POST /v1/enrich/batch: Enrich up to 100 descriptors
- GET /v1/merchants/{id}: Get a merchant
- GET /v1/categories: List the category taxonomy
- GET /v1/usage: Usage for the current billing period
Enriching
- POST /v1/enrich with {"descriptor": "<statement line, unchanged>"}. Add "country" (ISO 3166-1 alpha-2 of the card or account), "currency" (ISO 4217 code the transaction was paid in, not the card's billing currency) and "mcc" when you have them; they improve accuracy. Do not clean or shorten the descriptor yourself.
- For more than one descriptor use POST /v1/enrich/batch with {"items": [...]}, at most 100 items. Results come back in input order; an invalid item gets {"error": {...}} in its place without failing the batch.
- Read the result: merchant (name, category, subcategory, legal_name and website for the country of the transaction, logo_url, mcc) or null, location (where it happened; it can differ from the country you sent when the card was used abroad), processor (the payment aggregator or wallet), is_subscription, confidence (0 to 1), source, verified, kind, related.
- A non-null processor does not imply a purchase. Personal payments can return kind "transfer", a processor, and merchant null; do not send these lines for merchant identification.
- kind says what the line is: "purchase" (a payment to a merchant, even when merchant is null), "refund" (money back from the merchant in merchant), "declined" (did not go through, no money moved; a failed refund too), "notice" (no money moved: a limit changed, a card frozen, replaced or added to a phone wallet, a PIN changed, points earned, a payment due, a renewal, price change or cancellation coming up, a dispute opened, a fraud alert; merchant is who it is about, when named; never count it), "otp" (a one-time code message for a payment not made yet: no money moved, merchant is where it is being made, never count it), "promo" (an advert, not a transaction: normalized is empty, merchant is null, never count it), "preauth" (an amount held on the card, such as a hotel deposit, settled later for the final amount: never count it), "release" (a hold released, nothing charged: never count it, as spending or as a refund; merchant is who held it), "transfer" (between people or accounts, wallet top-ups, salary, money received from anyone including an insurance claim paid out, a payout or settlement from a business, money sent through a remittance house or app, which is in processor) or "bank" (written by the bank or wallet: fee, interest, cashback, cash withdrawal, card payment, a loan paid out, an instalment paid to a lender or pay-later provider, a purchase turned into instalments; related names the merchant or lender it is about; a salary from a company names the employer in related too). Count only purchases as spending at a merchant, subtract refunds, and never count declined, otp, preauth, release or notice lines. Decide from kind, not from merchant: refund, declined, otp, preauth, release and notice lines name a merchant too. Kind is read from Arabic messages as well as English ones.
- related is set on some bank lines: "Rs.6 cashback for your Dunzo order" has related.normalized "DUNZO", a loan repayment "paid to Bajaj Finance" has the lender, with related.merchant when we know it. Use it to link a cashback, an instalment or a loan repayment to its merchant or lender, not as the merchant of the line itself.
- merchant: null with confidence 0 is a normal 200 answer meaning "unknown". Show the original descriptor; never make up a merchant. When normalized is not empty, the line was read and that merchant is not in the database yet; when normalized is empty, the text named no merchant to look up (an advert, a code message, a fragment of a sentence).
- Use confidence to decide how to display a result, e.g. show the merchant above 0.8 and keep the descriptor visible below that. verified: true means our team approved the merchant record. source "ai" with verified: false is the AI's reading of the line, not a confirmed business: show it with less certainty.
- merchant.id can be null for a new merchant that is not reviewed yet. Do not use it as a required foreign key.
- Store the result with the transaction. The same descriptor gives the same answer, so cache by descriptor + country + currency instead of asking again.
Errors and limits
- Errors look like {"error": {"code", "message", "request_id"}}. Codes: invalid_request, unauthorized, not_found, quota_exceeded, rate_limited, internal_error.
- 429 rate_limited: wait for the Retry-After header (seconds), then retry.
- 500 or network errors: retry with exponential backoff. Enrichment is safe to retry.
- 400, 401, 402 (quota_exceeded): do not retry; fix the request, the key or the plan.
- GET /v1/usage returns the plan, used and remaining quota.
Write typed models for the request and response from the spec, a small client with timeouts and the retry rules above, and tests that cover merchant: null, a batch item error and a 429.
What I am building: <describe your app, language and framework>Tips
- Paste real descriptors from your data into the playground first, so you know what results look like.
- Give your assistant a sample response from the reference if it cannot open links.
- Review the generated code for where the key is read: it belongs in server-side configuration only.