Checking access…

Skip to main content

API Error Code Document Guidelines

Error documentation has two parts: an MDX page (user-facing) and JSON data files (structured error data rendered by the src/components/ErrorCodePage React components). All files live together in docs/03-Integration/5-convenient-checkout-api/4-error-codes/.

When to Use This Guide
  • Adding an error to an existing API's error page
  • Creating error documentation for a new API
  • Creating a reusable common error object
  • Documenting split-tender allocation errors

Quick Start​

I want to...Go to
Add an error to an existing APIAdding a New Error Code (edit the JSON; it renders automatically)
Create an error page for a new APICreating an MDX Error Code Page
Create a reusable error objectCreating Common Error Objects
Document split-tender allocation errorsDocumenting Allocation Errors
Look up fields or categoriesJSON Field Definitions, Error Categories

File Structure​

docs/03-Integration/5-convenient-checkout-api/4-error-codes/
β”œβ”€β”€ payment-error-codes.mdx ← MDX pages
β”œβ”€β”€ refund-error-codes.mdx
β”œβ”€β”€ session-error-codes.mdx
β”œβ”€β”€ payment-api.json ← API-specific JSON
β”œβ”€β”€ refund-api.json
β”œβ”€β”€ session-api.json
└── common/ ← Reusable objects
β”œβ”€β”€ agent-object.json
β”œβ”€β”€ config-object.json
β”œβ”€β”€ customer-object.json
β”œβ”€β”€ payment-allocation-object.json
β”œβ”€β”€ payment-consent-object.json
β”œβ”€β”€ payment-details-object.json
β”œβ”€β”€ payment-object.json
β”œβ”€β”€ session-consent-object.json
└── session-payment-object.json

src/components/ErrorCodePage/ ← React components (index.js)

There is no src/data/error-codes/ folder; the JSON sits beside the MDX. The MDX imports components from @site/src/components/ErrorCodePage and JSON from relative paths.

Adding a New Error Code​

The most common task: add one error to an existing API's JSON.

  1. Pick the category (see Error Categories) and use the category name exactly as it appears in that API's JSON file.
  2. Open {api-name}-api.json and add the error object to that category's errors array:
{
"id": "payment-amount-required",
"title": "INVALID_REQUEST",
"httpStatus": "400",
"message": "amount is required",
"scenario": ["When amount field is missing in the payment request"],
"resolution": "Include the amount field with a positive integer value.",
"scopeWithEndPoint": [
{ "merchant": ["POST /v2/payments"] }
],
"sampleResponse": {
"title": "INVALID_REQUEST",
"status": 400,
"detail": "amount is required"
},
"description": "Error returned when amount is missing."
}
  1. Verify. Run yarn start and open the error code page. The error renders when the category name matches exactly (case-sensitive), the JSON is valid, and the required fields are present.

Creating an MDX Error Code Page​

Create {api-name}-error-codes.mdx in the same folder. Use the categories that exist in your JSON file, in the standard order. Copy the heading text and category strings from the API's JSON (the example below uses the Payment API names).

---
sidebar_position: 2
slug: /integration/convenient-checkout-api/error-codes/{api-name}-error-codes
toc_max_heading_level: 4
audience: [consumers, ccg-platform-engineers]
---

import {
CategoryErrorSummary,
CategoryErrorDetails,
ToggleAllErrorsButton
} from '@site/src/components/ErrorCodePage';
import data from './{api-name}-api.json';

# {API Name} Error Codes

This page documents all error codes for the {API Name} (v2).

## Error Summary

### Authorization error

<CategoryErrorSummary data={data} category="Authorization error" />

### Schema validation error

<CategoryErrorSummary data={data} category="Schema validation error" />

## Error Details

<div style={{marginBottom: '1.5rem'}}>
<ToggleAllErrorsButton />
</div>

### Authorization error

<CategoryErrorDetails data={data} category="Authorization error" />

### Schema validation error

<CategoryErrorDetails data={data} category="Schema validation error" />

Add one Summary and one Details block for each category in the JSON. Add ObjectErrorSummary / ObjectErrorDetails blocks for common objects and AllocationErrorSummary / AllocationErrorDetails for allocation errors.

JSON Field Definitions​

Required fields​

FieldTypeExampleRules
idstring"payment-id-not-found"Unique within the file, kebab-case
titlestring"NOT_FOUND"UPPER_SNAKE_CASE
httpStatusstring"404"String, not number
messagestring"paymentId not found"Clear, user-facing
scenarioarray["valid paymentId but non-existent"]One bullet per case
resolutionstring or array"Verify the paymentId exists"Actionable guidance
sampleResponseobject{ "title": "NOT_FOUND", "status": 404 }Matches the API response
descriptionstring"Error returned when paymentId not found"One sentence

Optional fields​

The component renders all three of these when present; the real data files use all of them.

FieldTypeWhen to use
scopeWithEndPointarray of { scope: [endpoints] }Which scope and endpoint combinations return this error. Preferred for new errors.
endpointsarray of stringsEndpoints that return the error, when scope is not relevant
scopesarray of stringsScopes that can see the error, when endpoints are not relevant
allocationErrorsarrayAllocation-level error groups; see below

Error Categories​

The component matches category by exact string equality with the JSON categories[].name (CategoryErrorSummary / CategoryErrorDetails find the category by name; an unmatched name renders nothing). There is no fixed global list, and casing differs between files, so always copy the name from the API's JSON.

Category (lifecycle stage)Use whenName used in the current data
Authorization errorAPI Gateway blocks the request (OAuth, scope, merchant linking)Authorization error (payment, refund); Authorization Error (session)
Resource Not Found errorInvalid ID, non-existent resource, cross-merchant accessResource Not Found error (payment, refund); Resource Not Found Error (session)
Schema validation errorMissing fields, invalid JSON, type mismatchesSchema validation error (payment, refund, common objects)
Business rule violationDomain logic fails (refund greater than payment, duplicate ID)Business Rule Violation Error (payment, session, common objects); Business rule violation error (refund)
Payment processorProcessor-level failurePayment Processor Validation (payment); Payment processor error (refund)

Decision tree:

Does the request reach CCG Platform?
β”œβ”€ No β†’ Authorization error (API Gateway blocks it)
└─ Yes β†’ Does the resource exist?
β”œβ”€ No β†’ Resource Not Found error
└─ Yes β†’ Is the request structure valid?
β”œβ”€ No β†’ Schema validation error
└─ Yes β†’ Does it pass business rules?
β”œβ”€ No β†’ Business rule violation
└─ Yes β†’ Processor interaction
β”œβ”€ Parent-level failure β†’ Payment processor category
└─ Allocation-level failure β†’ Allocation errors (allocationErrors)

Creating Common Error Objects​

Create a common object when an object (such as customer or payment) appears in several APIs with consistent validation rules, so its errors have one source of truth.

  1. Create common/{object-name}-object.json:
{
"objectName": "Customer Object",
"description": "Validation errors for the customer object.",
"categories": [
{
"name": "Schema validation error",
"errors": [
{
"id": "customer-hsid-invalid-format",
"title": "INVALID_REQUEST",
"httpStatus": "400",
"message": "customer.hsid must be a valid UUID format",
"scenario": ["When customer.hsid is not in UUID format"],
"resolution": "Ensure customer.hsid is a valid UUID.",
"scopeWithEndPoint": [{ "merchant": ["POST /v2/payments"] }],
"sampleResponse": {
"title": "INVALID_REQUEST",
"status": 400,
"detail": "customer.hsid must be a valid UUID format"
},
"description": "Error returned when customer.hsid format is invalid."
}
]
}
]
}
  1. Register the object name in the API JSON's commonObjects array, for example "commonObjects": ["customer-object", "payment-object"].
  2. Import it in the MDX: import customerObject from './common/customer-object.json';
  3. Render it under the matching category in both sections. Pass category when the object has more than one:
#### Customer Object

<ObjectErrorSummary object={customerObject} category="Schema validation error" />
<ObjectErrorDetails object={customerObject} category="Schema validation error" />

Put the Summary call in the Error Summary section and the Details call in the Error Details section.

Documenting Allocation Errors​

Allocation errors apply to split tender operations where a parent transaction spawns several allocations that can fail independently with processor-specific codes. Use them when errors occur inside paymentAllocations[] or refundAllocations[].

allocationErrors belongs on the parent error object that represents the multi-allocation failure (in payment-api.json, the error inside the processor category). It is not a root-level field. Group entries by label (an error family), each with several processor code samples. sampleResponse in each entry is an array.

{
"id": "payment-processor-error",
"description": "Error returned when all paymentAllocations failed during processing.",
"allocationErrors": [
{
"label": "card_declined",
"description": "Card was declined without a specific reason. Customer should try a different payment method.",
"scenario": [
"This can happen when the payment processor returns:",
"card_declined: Card was declined for an unspecified reason"
],
"sampleResponse": [
{
"error": {
"title": "PAYMENT_ERROR",
"detail": "Payment method could not be authorized. Please try a different payment method.",
"errorDetails": { "code": "card_declined" }
}
}
]
}
]
}

Group by merchant action or customer messaging:

LabelUse forExample processor codes
card_declinedGeneric declinecard_declined, card_error, generic_decline
insufficient_fundsNot enough balanceinsufficient_funds
expired_cardExpired cardexpired_card
invalid_cardInvalid number or detailsinvalid_number, incorrect_cvc
blocked_cardBlocked or restrictedlost_card, stolen_card
issuer_authorization_requiredIssuer declined for securitydo_not_honor, pickup_card

If an error does not fit an existing label, add a new label named for the user action or error family.

In the MDX, render the components under their own headings in both sections, with a tip noting that allocation-level HTTP status is inherited from the parent response (see payment-error-codes.mdx for the exact admonitions):

### PaymentAllocation processor error

<AllocationErrorSummary data={data} />

Use <AllocationErrorDetails data={data} /> in the Error Details section. Include a caution that only known combinations are listed and that error.errorDetails reflects vendor data whose structure is not guaranteed.

Best Practices​

JSON

  • Use kebab-case id (customer-hsid-invalid-format), UPPER_SNAKE_CASE title, and string HTTP status codes ("404").
  • Write clear, actionable message and resolution values; cover every edge case in scenario.
  • Keep description to one sentence (it feeds the summary tables).
  • Always include a sampleResponse; never include internal error codes or stack traces.
  • Do not duplicate errors across common objects and API files.

MDX

  • Keep the Summary section before Details, with the same category order in both.
  • Import only the common objects you use.
  • Include the ToggleAllErrorsButton in Error Details and an introduction saying what the page covers.
  • Never hardcode error details in MDX; use JSON and the components.
  • Use one MDX page per API version.

Naming

ItemConventionExample
MDX file{api-name}-error-codes.mdxpayment-error-codes.mdx
JSON file{api-name}-api.jsonpayment-api.json
Common object{object-name}-object.jsoncustomer-object.json
Error ID{object}-{field}-{issue}customer-hsid-invalid-format
Allocation labelsnake_case error familyinsufficient_funds

Validation Checklist​

  • All required fields present on every error; IDs unique and kebab-case; titles UPPER_SNAKE_CASE; HTTP status is a string
  • Sample responses match the real API response; JSON is valid
  • Common objects used by the page are listed in commonObjects and imported in the MDX
  • MDX frontmatter has sidebar_position, slug, toc_max_heading_level, and audience: [consumers, ccg-platform-engineers]
  • Every category string matches the JSON name exactly (case-sensitive)
  • Summary comes before Details; Toggle All button is present; allocation components are included where relevant
  • No internal implementation details are exposed
  • The page renders in yarn start, and yarn -s lint:docs passes

FAQs​

Can an error appear in several categories? Yes; add separate error objects under each category.

Same error across several APIs? Use a common object if the validation is identical; otherwise duplicate it in each API's JSON with API-specific details.

Updating an error message? Edit the JSON only; the MDX reflects it.

Processor codes that vary by vendor? List the variants in scenario, show several sampleResponse entries, and include the vendor-structure caveat.

Every HTTP status? Document application-level errors only. Generic infrastructure errors (500, 503) need no entry unless there is app-specific context.

Custom sections in the MDX? Yes, with clear headings, but keep the Summary then Details structure.

Troubleshooting​

Component renders nothing or raw JSON

  • Check the category string against the JSON name (case-sensitive; Payment Processor Validation is not Payment Processor Error).
  • Check the JSON import path and syntax, and the browser console.

Error missing from the summary table

  • Verify the category name and that the error sits in the right category array.
  • Check description is present; clear the cache with yarn clear && yarn start.

Sample response not formatting

  • sampleResponse must be an object (an array for allocationErrors entries); check JSON syntax.

Allocation errors not showing

  • allocationErrors must be on the parent error object inside categories[].errors[], not at the root.
  • Each entry needs label and description, and sampleResponse must be an array.

Reference​