API referenceLetters

Price a physical-mail letter without creating it

Returns the exact price of a letter without creating one — no side effects, nothing stored.

Endpoint
POST https://api.dairo.app/v1/letters/price

Returns the exact price of a letter without creating one — no side effects, nothing stored. Provide country plus either pageCount (minimum 1) or pdfBase64, in which case Dairo counts the pages of the actual file; print and delivery default to the same values as the create call (grayscale, simplex, economy). The response is a letter_price whose upper-case currency and amount (VAT included) are what the letter is billed when mailed. The quote runs the same destination and option validation as POST /v1/letters, so a successful quote also confirms the combination is sendable. Requires only the letters:read scope, so a read-only key can quote prices.

Scope: letters:read. Send the API key as a bearer token; Scopes lists what each one reaches.

Request

cURL
curl -X POST "https://api.dairo.app/v1/letters/price" \
  -H "Authorization: Bearer $DAIRO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Body

Required, application/json: LetterPriceRequest.

Give the destination (country or to.country) and one page source: pageCount, pdfBase64, file, or templateId (rendered with templateData and to to count pages). First match wins in that order.

FieldTypeRequiredDescription
countrystringnoISO 3166-1 alpha-2 country code. Optional when to.country is given.
pageCountinteger or nullno(minimum 1)
pdfBase64string or nullno
printLetterPrintOptionsno
deliveryLetterDeliveryno
paperTypesarray of LetterPaperTypeno
fileLetterFileRefno
templateIdstring or nullnoA stored letter template; rendered to count pages.
templateDataobject or nullnoValues for the template's placeholders.
toPostalAddress or nullnoRecipient. Its country prices the letter when country is absent; a template render composites it (a sample recipient is used when absent).

Response

200 Success. Body: application/json, LetterPrice.

FieldTypeRequiredDescription
object"letter_price"yes
currencystringyesUpper-case ISO 4217 code, e.g. EUR.
amountnumberyesThe price the letter is billed, VAT included (the same gross basis as the charge).
walletAmountnumbernoThe price in the credits-wallet currency, at the same conversion rate the charge uses (rounded to the cent).
walletCurrencystringnoThe credits-wallet currency (USD).
walletRatenumbernoThe conservative rate from the letter currency (EUR) to the wallet currency used for walletAmount (walletAmount = amount × walletRate, rounded to the cent).
countrystringno
pageCountintegerno
deliveryLetterDeliveryno
printLetterPrintOptionsno
breakdownobjectno
200
{
  "object": "letter_price",
  "currency": "EUR",
  "amount": 0,
  "walletAmount": 0,
  "walletCurrency": "string",
  "walletRate": 0,
  "country": "DE",
  "pageCount": 0,
  "delivery": "economy",
  "print": {
    "mode": "color",
    "sides": "simplex",
    "addressPlacement": "left"
  },
  "breakdown": {
    "providerCost": {
      "currency": "EUR",
      "amount": 0,
      "walletAmount": 0,
      "walletCurrency": "string",
      "walletRate": 0
    },
    "marginPct": 0
  }
}

Errors

Every error has the same body, {"error": {"type", "code", "message", "param"}}; branch on code. Errors lists every code.

StatusMeaning
400The request is malformed or a value is invalid (invalid_request, invalid_domain, idempotency_key_mismatch).
401The API key is missing or invalid.
403The key lacks the scope this endpoint needs (scope_missing) or may not do this (not_permitted).
404No such resource in this account (resource_not_found).
422The request is well-formed but a field failed validation (validation_failed).
429Rate limit, plan limit, budget or spend cap reached (rate_limited, plan_limit_reached, budget_exceeded, spend_cap_reached).
500An unexpected error; retry with backoff, then contact support (internal_error).

On this page