API v1

Errors, idempotency, pagination & rate limits

Error envelope

Every /v1 error has the same shape and a machine-readable code:

{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Request validation failed",
    "details": { "fields": ["amountKobo must not be less than 100"] },
    "requestId": "req_5b8c0c8e-1f2a-4c7d-9a0b-3e4f5a6b7c8d",
    "retryable": false
  }
}

retryable: true means sending the same request again later can succeed; false means fix the request first.

HTTPcodeWhat to do
400INVALID_REQUESTFix the request. details.fields lists validation problems.
400REFERENCE_REQUIREDA charge needs a reference (or an Idempotency-Key).
401UNAUTHENTICATEDMissing, invalid, expired or revoked key. Don't retry.
403FORBIDDENMissing scope (named in the message) or IP not allowed.
403LIVE_ACCESS_NOT_APPROVEDA live key whose account isn't currently approved (or is suspended). Test keys still work.
404NOT_FOUNDNo such resource for you in this environment — including another developer's or the other environment's.
409DUPLICATE_REFERENCEThat charge reference is already used. details.chargeId is the existing charge — fetch it rather than creating another.
409IDEMPOTENCY_KEY_REUSEDSame Idempotency-Key, different body. Use a new key for a different request.
409REQUEST_IN_PROGRESSSame Idempotency-Key, first request still running. Retry shortly (retryable).
422VALIDATION_ERRORBusiness collections only: LIMIT_EXCEEDED, or the business still has KYC to complete.
429RATE_LIMITEDWait for Retry-After seconds, then retry.
500INTERNAL_ERRORUnexpected failure on our side. Contact support with the requestId if it persists.
502PROVIDER_ERRORThe payment provider failed (e.g. the transfer account couldn't be opened). Nothing was charged. Retry with the same reference.
503ENVIRONMENT_UNAVAILABLEThis deployment doesn't serve the key's environment. Never falls back to the other one.
503SERVICE_UNAVAILABLETemporarily unavailable (e.g. fee schedule maintenance). Retry later.

Request ids

Every response has an X-Request-ID header (also error.requestId). Send your own as X-Request-ID (letters, digits, _ and -, up to 100) to correlate with your logs; otherwise one is generated. Your dashboard's Request logs are searchable by it.

References, idempotency and retries

A charge's reference is your business identifier and is unique per account per environment, enforced by the database. Re-sending a create with a used reference returns 409 DUPLICATE_REFERENCE — never a second charge — so a charge create is always safe to retry with the same reference.

Idempotency-Key is a separate, optional retry tool (required on POST /v1/payment-links). Up to 200 characters, scoped to your API key and the endpoint, kept for 24 hours:

  • Same key + same body → the original response is replayed; nothing new is created.
  • Same key + different body → 409 IDEMPOTENCY_KEY_REUSED.
  • Same key while the first request is still running → 409 REQUEST_IN_PROGRESS; retry shortly.
  • If the first attempt failed, the key is freed — retry with it.
// Retry safely: the SAME reference for the same order means a retry can never
// create a second charge. On 409 DUPLICATE_REFERENCE, the first attempt worked.
async function createChargeWithRetry(order) {
  const body = { reference: order.id, amountKobo: order.amountKobo, customer: { email: order.email } };
  for (let attempt = 1; attempt <= 4; attempt++) {
    try {
      const res = await fetch("https://api.developers.sendjoor.com/v1/charges", {
        method: "POST",
        headers: { Authorization: `Bearer ${process.env.SENDJOOR_SECRET_KEY}`, "Content-Type": "application/json" },
        body: JSON.stringify(body),
        signal: AbortSignal.timeout(30_000),
      });
      const data = await res.json();
      if (res.ok) return data;
      if (data.error.code === "DUPLICATE_REFERENCE") {
        return getChargeByReference(order.id); // GET /v1/charges/reference/{reference}
      }
      if (!data.error.retryable) throw new Error(`${data.error.code}: ${data.error.message}`);
    } catch (err) {
      if (attempt === 4) throw err; // timeouts and network errors land here too — retrying is safe
    }
    await new Promise((r) => setTimeout(r, 2 ** attempt * 250));
  }
}

Exactly-once settlement

Independently of all this, a payment is credited exactly once: settlement is claimed atomically, so a webhook, a verify call and a retry racing each other can never double-credit, and duplicate provider notifications are ignored.

Pagination

List endpoints take page (from 1) and limit (1–100, default 25), return newest first, and respond with { items, total, page, limit, pageCount }.

Rate limits

300 requests per minute per endpoint, counted per client IP address. Creating business collections is limited to 60 per minute. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset(seconds); a 429 adds Retry-After.

Amounts and timestamps

Money is always an integer number of kobo (₦1 = 100 kobo); never send decimals. Currency is NGN. Timestamps are ISO-8601 in UTC.