logo
ReferenceCommon errors

Common errors

Diagnose and fix the most frequent errors

Overview

This guide helps you fix the most common issues when calling the Conta Simples API. Errors are grouped by HTTP status.

Before opening a ticket, go through the diagnostic checklist at the end of this page.


Errors by endpoint

GET /statements/v1/credit-card

CodeDescriptionCommon meaning
200OKSuccess
400Bad RequestInvalid parameters
500Internal Server ErrorServer error

GET /attachments/v1/content/{attachmentId}

CodeDescriptionCommon meaning
200OKSuccess (binary body)
404Not FoundAttachment does not exist

Validation errors (400)

Symptoms

  • 400 Bad Request
  • Invalid parameters in the request

Common causes for GET /statements/v1/credit-card


Authentication errors (401)

Symptoms

  • 401 Unauthorized
  • Messages about invalid, expired, or missing token

Causes and fixes

Retry pattern for 401

async function requestWithAuthRetry(
  method: string,
  url: string,
  options: RequestInit & { headers: Record<string, string> },
): Promise<Response> {
  let response = await fetch(url, { method, ...options });

  if (response.status === 401) {
    invalidateTokenCache();
    const newToken = await getFreshToken();
    options.headers["Authorization"] = `Bearer ${newToken}`;
    response = await fetch(url, { method, ...options });
  }

  return response;
}

Permission errors (403)

Symptoms

  • 403 Forbidden
  • “No permission”, “Access denied”, “Insufficient scope”

Causes and fixes


Not found (404)

Symptoms

  • 404 Not Found
  • Resource not found

For GET /attachments/v1/content/{attachmentId}


Server errors (5xx)

Symptoms

  • 500 Internal Server Error (or other 5xx)

What to do

Wait and retry

5xx can be temporary. Wait a few seconds and try again.

Use backoff

Exponential backoff so you do not hammer the service.

Log the incident

Note the time and the parameters you sent.

Open a ticket if it continues

If it still fails after 3–5 attempts, contact support.

Retry pattern for 5xx

const RETRYABLE_STATUS = new Set([500, 502, 503, 504]);

async function requestWithRetry(
  method: string,
  url: string,
  maxRetries = 3,
  options?: RequestInit,
): Promise<Response> {
  for (let attempt = 0; attempt < maxRetries; attempt++) {
    try {
      const controller = new AbortController();
      const timeout = setTimeout(() => controller.abort(), 30_000);
      const response = await fetch(url, {
        method,
        ...options,
        signal: controller.signal,
      });
      clearTimeout(timeout);
      if (!RETRYABLE_STATUS.has(response.status)) {
        return response;
      }
    } catch (err) {
      if (!(err instanceof DOMException && err.name === "AbortError"))
        throw err;
    }
    if (attempt < maxRetries - 1) {
      const waitTime = 2 ** attempt + Math.random();
      await new Promise((resolve) => setTimeout(resolve, waitTime * 1000));
    }
  }
  throw new Error("Max retries exceeded");
}

Diagnostic checklist

Before you contact support:

  • Base URL matches the environment (Sandbox / Production)
  • Token is still within expires_in (about 30 minutes)
  • Authorization is Bearer {TOKEN} with a space
  • Content-Type is application/json when a body is sent
  • JSON is valid
  • Dates use YYYY-MM-DD
  • Range is at most 62 days
  • limit is between 5 and 100
  • You retried after a short wait (for 5xx)

What to include with support

When you contact support, always include:

ItemDescriptionExample
TimestampExact time (UTC)2025-01-15T14:30:00Z
EnvironmentSandbox or ProductionSandbox
EndpointMethod and pathGET /statements/v1/credit-card
StatusHTTP status400
RequestRedacted body or querySee below
ResponseAPI responseSee below

Example of redacted payload

{
  "startDate": "2025-01-01",
  "endDate": "2025-01-31",
  "limit": 50
}
{
  "error": "Bad Request",
  "message": "startDate format is invalid"
}

Never put tokens, secrets, or personal data in your report.