# Obtener un documento

Permiso requerido: invoices:read.

GET `/public/v1/invoices/{id}`

Permiso `invoices:read` · Facturación

## Parámetros

### Parámetros de ruta

| Nombre | Tipo          | Requerido | Descripción |
| ------ | ------------- | --------- | ----------- |
| `id`   | string (uuid) | Sí        | —           |

## Ejemplo de petición

**curl**

```sh
curl "https://api.posdata.so/public/v1/invoices/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d" \
  -H "Authorization: Bearer $POSDATA_API_KEY"
```

**Node.js**

```js
const res = await fetch('https://api.posdata.so/public/v1/invoices/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d', {
  headers: {
    Authorization: `Bearer ${process.env.POSDATA_API_KEY}`,
  },
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message} (${data.error.request_id})`);
```

**Python**

```python
import os

import requests

res = requests.get(
    "https://api.posdata.so/public/v1/invoices/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
    headers={
        "Authorization": f"Bearer {os.environ['POSDATA_API_KEY']}",
    },
    timeout=30,
)
data = res.json()
if not res.ok:
    raise RuntimeError(f"{data['error']['code']}: {data['error']['message']} ({data['error']['request_id']})")
```

**PHP**

```php
<?php
$ch = curl_init('https://api.posdata.so/public/v1/invoices/3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('POSDATA_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
    throw new RuntimeException("{$data['error']['code']}: {$data['error']['message']} ({$data['error']['request_id']})");
}
```

## Respuesta

`200` OK: un objeto [Invoice](https://developers.posdata.so/referencia/objetos/#obj-invoice).

| Campo              | Tipo                                                                               | Requerido | Descripción                                                           |
| ------------------ | ---------------------------------------------------------------------------------- | --------- | --------------------------------------------------------------------- |
| `object`           | `"invoice"`                                                                        | Sí        | —                                                                     |
| `id`               | string (uuid)                                                                      | Sí        | —                                                                     |
| `sale_id`          | string (uuid) \| null                                                              | Sí        | —                                                                     |
| `document_type`    | [DocumentType](https://developers.posdata.so/referencia/objetos/#obj-documenttype) | Sí        | —                                                                     |
| `type_document_id` | integer \| null                                                                    | Sí        | Código del tipo de documento DIAN (1, 15, 26).                        |
| `status`           | string                                                                             | Sí        | pending, issued, rejected, emission_failed, annulled.                 |
| `dian_status`      | string \| null                                                                     | Sí        | —                                                                     |
| `dian_message`     | string \| null                                                                     | Sí        | Mensaje de la DIAN; solo cuando el documento fue emitido o rechazado. |
| `document_reason`  | string \| null                                                                     | Sí        | Por qué se eligió este tipo de documento.                             |
| `prefix`           | string \| null                                                                     | Sí        | —                                                                     |
| `number`           | integer                                                                            | Sí        | —                                                                     |
| `cufe`             | string \| null                                                                     | Sí        | CUFE (factura) o CUDE (documento POS).                                |
| `subtotal`         | integer                                                                            | Sí        | Pesos colombianos (COP), entero sin decimales.                        |
| `tax`              | integer                                                                            | Sí        | Pesos colombianos (COP), entero sin decimales.                        |
| `total`            | integer                                                                            | Sí        | Pesos colombianos (COP), entero sin decimales.                        |
| `issued_at`        | string (date-time)                                                                 | Sí        | —                                                                     |
| `created_at`       | string (date-time)                                                                 | Sí        | —                                                                     |
| `updated_at`       | string (date-time)                                                                 | Sí        | —                                                                     |

```json
{
  "object": "invoice",
  "id": "3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
  "sale_id": "3f1c2e8d-7a10-4d0b-9a57-0b6f2f0e5c1d",
  "document_type": "electronic_invoice",
  "type_document_id": 1,
  "status": "texto",
  "dian_status": "texto",
  "dian_message": "texto",
  "document_reason": "texto",
  "prefix": "texto",
  "number": 1,
  "cufe": "texto",
  "subtotal": 25900,
  "tax": 1,
  "total": 25900,
  "issued_at": "2026-09-28T15:04:05.000Z",
  "created_at": "2026-09-28T15:04:05.000Z",
  "updated_at": "2026-09-28T15:04:05.000Z"
}
```

## Errores

Todo error responde con un objeto [Error](https://developers.posdata.so/referencia/objetos/#obj-error) y un `request_id`. Ramifica por `error.code`, nunca por el mensaje.

### 400Petición inválida (VALIDATION_ERROR, INVALID_JSON, INVALID_CURSOR).

**Respuesta 400**

Cuerpo: un objeto [Error](https://developers.posdata.so/referencia/objetos/#obj-error). Qué significa cada código y qué hacer: [Errores](https://developers.posdata.so/errores/).

VALIDATION_ERRORINVALID_JSONINVALID_CURSOR

### 401Sin API key válida (UNAUTHENTICATED, INVALID_API_KEY, API_KEY_REVOKED, API_KEY_EXPIRED, API_KEY_WRONG_ENVIRONMENT, ACCOUNT_INACTIVE).

**Respuesta 401**

Cuerpo: un objeto [Error](https://developers.posdata.so/referencia/objetos/#obj-error). Qué significa cada código y qué hacer: [Errores](https://developers.posdata.so/errores/).

UNAUTHENTICATEDINVALID_API_KEYAPI_KEY_REVOKEDAPI_KEY_EXPIREDAPI_KEY_WRONG_ENVIRONMENTACCOUNT_INACTIVE

### 403Sin permiso (PLAN_REQUIRED, INSUFFICIENT_SCOPE, BROWSER_REQUESTS_NOT_ALLOWED).

**Respuesta 403**

Cuerpo: un objeto [Error](https://developers.posdata.so/referencia/objetos/#obj-error). Qué significa cada código y qué hacer: [Errores](https://developers.posdata.so/errores/).

PLAN_REQUIREDINSUFFICIENT_SCOPEBROWSER_REQUESTS_NOT_ALLOWED

### 404No existe en esta cuenta (NOT_FOUND).

**Respuesta 404**

Cuerpo: un objeto [Error](https://developers.posdata.so/referencia/objetos/#obj-error). Qué significa cada código y qué hacer: [Errores](https://developers.posdata.so/errores/).

NOT_FOUND

### 429Límite de peticiones (RATE_LIMITED). Respeta Retry-After.

**Respuesta 429**

Cuerpo: un objeto [Error](https://developers.posdata.so/referencia/objetos/#obj-error). Qué significa cada código y qué hacer: [Errores](https://developers.posdata.so/errores/).

RATE_LIMITED

### 500Error interno (INTERNAL_ERROR). Reintenta y comparte el request_id si persiste.

**Respuesta 500**

Cuerpo: un objeto [Error](https://developers.posdata.so/referencia/objetos/#obj-error). Qué significa cada código y qué hacer: [Errores](https://developers.posdata.so/errores/).

INTERNAL_ERROR

---

Fuente: https://developers.posdata.so/referencia/operations/getinvoice/ · Índice para agentes: https://developers.posdata.so/llms.txt
