Skip to main content

Quickstart

This guide assumes you already have an API key (odt_...) against a company in test environment. If you don't have one yet, see Authentication.

Issue an invoice (type 01)

Copy, paste your API key in place of odt_xxx, and run:

curl
curl -X POST https://ocote.io/api/connect/invoice \
-H "Authorization: Bearer odt_xxx" \
-H "Content-Type: application/json" \
-d '{
"doc_type": "01",
"external_ref": "MY-FIRST-INVOICE-001",
"lines": [
{ "description": "Consulting service", "quantity": 1, "unit_price": 100.00 }
]
}'
Node.js (axios)
import axios from 'axios';

const { data } = await axios.post(
'https://ocote.io/api/connect/invoice',
{
doc_type: '01',
external_ref: 'MY-FIRST-INVOICE-001',
lines: [
{ description: 'Consulting service', quantity: 1, unit_price: 100.00 },
],
},
{ headers: { Authorization: `Bearer ${process.env.OCOTE_API_KEY}` } }
);

console.log(data);
Python (requests)
import os, requests

r = requests.post(
"https://ocote.io/api/connect/invoice",
headers={"Authorization": f"Bearer {os.environ['OCOTE_API_KEY']}"},
json={
"doc_type": "01",
"external_ref": "MY-FIRST-INVOICE-001",
"lines": [
{"description": "Consulting service", "quantity": 1, "unit_price": 100.00},
],
},
)
r.raise_for_status()
print(r.json())
PHP (Guzzle)
use GuzzleHttp\Client;

$client = new Client(['base_uri' => 'https://ocote.io/api/connect/']);

$response = $client->post('invoice', [
'headers' => ['Authorization' => 'Bearer ' . getenv('OCOTE_API_KEY')],
'json' => [
'doc_type' => '01',
'external_ref' => 'MY-FIRST-INVOICE-001',
'lines' => [
['description' => 'Consulting service', 'quantity' => 1, 'unit_price' => 100.00],
],
],
]);

echo $response->getBody();

Expected response

{
"success": true,
"dte_success": true,
"contingency": false,
"rejected": false,
"posted": true,
"is_duplicate": false,
"document_id": "a1b2c3d4-1234-5678-9abc-def012345678",
"external_ref": "MY-FIRST-INVOICE-001",
"control_number": "DTE-01-M001P001-000000000000123",
"generation_code": "A1B2C3D4-1234-5678-9ABC-DEF012345678",
"reception_stamp": "20260421154532...",
"dte_state": "",
"dte_message": "",
"observaciones": [],
"codigo_msg": "",
"ticket_url": "https://ocote.io/api/connect/file/a1b2c3d4-1234-5678-9abc-def012345678?type=ticket&key=odt_xxx",
"json_url": "https://ocote.io/api/connect/file/a1b2c3d4-1234-5678-9abc-def012345678?type=json&key=odt_xxx"
}

What just happened:

  1. Ocote created the document with the external_ref you sent.
  2. Assigned the fiscal correlative control_number.
  3. Digitally signed it and sent it to MH.
  4. MH returned the reception_stamp (reception seal).
  5. The ticket PDF and signed JSON were generated, accessible via the URLs in the response.

Open the ticket

Paste ticket_url into your browser. You get a PDF ready to print on an 80 mm thermal printer or to archive.

Query the state afterwards

Use your external_ref (or the document_id) to query any document at any time:

curl "https://ocote.io/api/connect/status/MY-FIRST-INVOICE-001" \
-H "Authorization: Bearer odt_xxx"

The response carries the same flags (success, dte_success, contingency, rejected…), plus DTE amounts and file URLs.

What to explore next