Overview

The Contazen API supports localization for error messages and responses. Currently, the API supports:
  • English (en) - Default
  • Romanian (ro)

Setting the Language

There are three ways to specify your preferred language: Use the standard HTTP Accept-Language header:
curl https://api.contazen.ro/v1/clients \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Accept-Language: ro"

2. Query Parameter

Include the locale parameter in the URL:
curl https://api.contazen.ro/v1/clients?locale=ro \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"

3. Request Body

For POST and PUT requests, include locale in the JSON body:
curl -X POST https://api.contazen.ro/v1/invoices \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "locale": "ro",
    "client_id": "9z8y7x6w5v",
    "items": [...]
  }'

Priority

If multiple methods are used, the API follows this priority order:
  1. Query parameter (?locale=ro)
  2. Request body ("locale": "ro")
  3. Accept-Language header
  4. Default to English (en)

Response Header

The API includes a Content-Language header in all responses to indicate the language used:
HTTP/1.1 200 OK
Content-Type: application/json
Content-Language: ro

Localized Elements

The following elements are localized:

Error Messages

{
  "success": false,
  "error": {
    "message": "Validation failed",
    "type": "validation_error",
    "errors": {
      "cui": "CUI/CIF is required for B2B clients",
      "address": "Address is required"
    }
  }
}

Field Labels

Field validation messages are localized based on the context:
EnglishRomanian
Name is requiredNumele este obligatoriu
Invalid email formatFormat email invalid
Invoice not foundFactura nu a fost găsită
Client not foundClientul nu a fost găsit
Due date cannot be before invoice dateData scadentă nu poate fi înainte de data facturii

Examples

Creating an Invoice with Romanian Errors

Request:
curl -X POST https://api.contazen.ro/v1/invoices \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Accept-Language: ro" \
  -H "Content-Type: application/json" \
  -d '{
    "items": []
  }'
Response:
{
  "success": false,
  "error": {
    "message": "Validarea a eșuat",
    "type": "validation_error",
    "code": "invalid_request",
    "status": 400,
    "errors": {
      "items": "Cel puțin un articol este necesar",
      "client_id": "Clientul este obligatoriu"
    }
  },
  "meta": {
    "version": "v1",
    "response_time": "12.34ms"
  }
}

Retrieving Non-existent Client

Request:
curl https://api.contazen.ro/v1/clients/invalid_id?locale=ro \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY"
Response:
{
  "success": false,
  "error": {
    "message": "Clientul nu a fost găsit",
    "type": "not_found_error",
    "code": "resource_not_found",
    "status": 404
  },
  "meta": {
    "version": "v1",
    "response_time": "8.91ms"
  }
}

Language Detection

If no language preference is specified, the API attempts to detect the language from the Accept-Language header:
  • If the header contains ro (e.g., ro-RO, ro), Romanian is used
  • Otherwise, English is used as the default

Best Practices

  1. Consistency - Use the same language setting method throughout your application
  2. User Preference - Store user language preferences and apply them to all API requests
  3. Fallback Handling - Always handle English responses as a fallback
  4. Header Method - Prefer the Accept-Language header for RESTful compliance

Notes

Success messages and data field names remain in English regardless of the locale setting. Only error messages and validation messages are localized.
Not all error messages may be translated. If a translation is missing, the English version will be returned as a fallback.