# The response envelope: data, error and request_id

> Every endpoint wraps its result the same way. Parse the envelope once, centrally, and the 100-odd endpoint shapes only ever reach your code as `data`.

Source: https://astronode.dev/reference/response-envelope · Updated: 2026-12-01

A successful response has four top-level keys: `request_id`, `data` (the endpoint's result), `interpretation` (a prose summary on endpoints that offer one, otherwise `null`) and `meta` (`engine_version`, `computed_at`). An error response has exactly two: `request_id` and `error`.

There is no `success` boolean - the HTTP status and the presence of `error` are the signal.

## Envelope fields

| Field | Present on | Type | Meaning |
| --- | --- | --- | --- |
| `request_id` | every response | `string` | `req_` followed by a 26-character ULID. Also sent as the `x-request-id` response header. Quote it when you contact support. |
| `data` | 2xx | `object` | The endpoint's result. Shape varies by endpoint; see each endpoint page. |
| `interpretation` | 2xx | `object \| null` | `null` on most calculation endpoints. Where present: `type`, `summary`, `highlights[]`, `language`, `version`. |
| `meta.engine_version` | 2xx | `string` | Semantic version of the calculation engine that produced `data`. |
| `meta.computed_at` | 2xx | `string` | ISO 8601 UTC instant the response was computed - the only wall-clock value in a calculation response. |
| `error.code` | 4xx / 5xx | `string` | Stable SCREAMING_SNAKE_CASE code from the table below. Branch on this, never on `message`. |
| `error.message` | 4xx / 5xx | `string` | Human-readable, may change wording. |
| `error.details` | some errors | `any` | Optional structured context: field-level issues for `VALIDATION_ERROR`, `retry_after_seconds` for `RATE_LIMITED`, and so on. |

## Error codes

The API's canonical code list. Codes are never renamed or reused.

| code | Meaning |
| --- | --- |
| `VALIDATION_ERROR` | Request validation failed; see `details` for field-level issues. |
| `INVALID_DOB` | `date` is not a valid ISO 8601 date. |
| `INVALID_TIME` | `time` is not a valid HH:mm[:ss] string. |
| `INVALID_COORDINATES` | lat/lng outside the valid -90..90 / -180..180 range. |
| `IDEMPOTENCY_KEY_REUSED` | Idempotency-Key was reused with a different request body. |
| `UNAUTHORIZED` | Missing or invalid Authorization header. |
| `FORBIDDEN` | API key is valid but not allowed to perform this action. |
| `PLAN_REQUIRED` | This endpoint is not included in the caller's current plan; upgrade to unlock. |
| `NOT_FOUND` | The requested resource does not exist. |
| `RATE_LIMITED` | Per-minute rate limit exceeded; back off and retry. |
| `QUOTA_EXCEEDED` | Monthly quota exhausted; upgrade your plan to continue. |
| `INTERNAL_ERROR` | Unexpected server error; safe to retry. |
| `ENGINE_TIMEOUT` | Astrology engine exceeded its compute deadline. |
| `SERVICE_UNAVAILABLE` | A required dependency is down; retry with backoff. |
| `TOOLS_PAUSED` | The free public tools are temporarily switched off by the operator; retry later. |

## Things to watch

- Read `data`, not the root: `body.data.planets`, never `body.planets`. Chart endpoints also have a `meta` INSIDE `data` (the ayanamsa and house system) - a different object from the envelope's `meta`.
- `VALIDATION_ERROR` puts its field issues in `details` as an array of `{ keyword, instancePath, message, params }` objects - `instancePath` (`"/tz_offset_minutes"`) is the field to highlight.
- Authentication is checked before the body: a request with no or an invalid key returns `401 UNAUTHORIZED`, never a `VALIDATION_ERROR`, however malformed the body. Fix the key first when debugging a 401.
- Some 400s are raised by the endpoint after schema validation (an unsupported varga division, for example). Those carry `VALIDATION_ERROR` with a `message` but no `details`.
- Send your own `x-request-id` (`req_` plus at least 20 alphanumerics) to trace a call across your services; the API adopts it instead of minting one. Anything else in that header is ignored.
- Status codes: 400 for `VALIDATION_ERROR` and the `INVALID_*` codes, 409 `IDEMPOTENCY_KEY_REUSED`, 401 `UNAUTHORIZED`, 403 `FORBIDDEN` / `PLAN_REQUIRED`, 404 `NOT_FOUND`, 429 `RATE_LIMITED` / `QUOTA_EXCEEDED`, 5xx for the rest (`TOOLS_PAUSED` is a 503). `INTERNAL_ERROR` and `SERVICE_UNAVAILABLE` are safe to retry with backoff.

## Example: POST /v1/charts/birth

Real responses from an in-memory run of the API (2026-12-01): a success (planets cut to one) and the 400 for `"tz_offset_minutes": 5.5`.

```json
{
  "request_id": "req_01M8RERB1JBKRYERX2YD56GSR1",
  "data": {
    "ascendant": { "sign": "Leo", "degree": 9.935824007692588 },
    "planets": [
      { "name": "Sun", "sign": "Gemini", "house": 11, "degree_in_sign": 18.426008095609006,
        "nakshatra": "Ardra", "nakshatra_pada": 4, "retrograde": false }
    ],
    "meta": { "ayanamsa": "lahiri", "house_system": "whole_sign", "engine_version": "1.2.1" }
  },
  "interpretation": null,
  "meta": { "engine_version": "1.2.1", "computed_at": "2026-12-01T09:25:13.942Z" }
}

{
  "request_id": "req_01M8RERB2SQWRQG8PS2P3QYBYJ",
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Request validation failed",
    "details": [
      { "keyword": "invalid_type", "instancePath": "/tz_offset_minutes",
        "message": "Invalid input: expected int, received number" }
    ]
  }
}
```

## Questions

**Which endpoints does this page apply to?**

3 endpoints: Birth Chart (Kundli) (`POST /v1/charts/birth`); Ayanamsa Systems (`GET /v1/ayanamsa`); Divisional Charts (Navamsa, D1-D60) (`POST /v1/charts/varga`).

## Endpoints

- [`POST /v1/charts/birth`](https://astronode.dev/capabilities/vedic/charts-birth) - Birth Chart (Kundli) API
- [`GET /v1/ayanamsa`](https://astronode.dev/capabilities/vedic/ayanamsa) - Ayanamsa Systems API
- [`POST /v1/charts/varga`](https://astronode.dev/capabilities/vedic/charts-varga) - Divisional Charts (Navamsa, D1-D60) API
