CapData API Examples

This section provides practical examples of how to use the CapData API endpoints with real-world scenarios.

Authentication Examples

Using API Key

GET /api/contacts HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here
Content-Type: application/json

Using Employee Token

GET /api/contacts HTTP/1.1
Host: capdata.es
X-Employee-Token: your_employee_token_here
Content-Type: application/json

Main API Examples

Extract Flight Data

POST /api/extract HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here
Content-Type: application/json

{
  "html": "<html>Flight booking HTML content</html>",
  "context": {
    "is_vueling": false
  },
  "include_avsis": false
}

Send to Clientify

POST /api/sendToClientify HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here
Content-Type: application/json

{
  "clientify_token": "your_clientify_token",
  "flight_data": {
    "codigo_reserva": "ABC123",
    "nombre_pasajero": "John Doe",
    "aerolinea": "Iberia",
    "fecha_vuelo": "2025-01-15"
  }
}

List Contacts with Pagination

GET /api/contacts?page=1&per_page=50&search=john&entity_type=person&role=passenger HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here

Chat API Examples

Create Chat Folder

POST /api/chat/folders HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here
Content-Type: application/json

{
  "name": "Customer Support"
}

Send Message

POST /api/chat/conversations/1/messages HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here
Content-Type: application/json

{
  "content": "Hello, I need help with my booking",
  "conversation_id": 1
}

Management API Examples

Create Agency

POST /api/management/agencies HTTP/1.1
Host: capdata.es
X-Owner-API-Key: your_owner_api_key_here
Content-Type: application/json

{
  "name": "Travel Agency Madrid",
  "email": "contact@travelmadrid.com",
  "password": "secure_password",
  "consumes_owner_tokens": true,
  "contact_person": "María García",
  "phone_number": "+34123456789"
}

Create Agent

POST /api/management/agents HTTP/1.1
Host: capdata.es
X-Owner-API-Key: your_owner_api_key_here
Content-Type: application/json

{
  "name": "Carlos López",
  "username": "carlos_lopez",
  "password": "secure_password"
}

Integrations API Examples

List Integrations

GET /api/v1/integrations HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here

Update Integration

PUT /api/v1/integrations/visagov HTTP/1.1
Host: capdata.es
X-API-Key: your_api_key_here
Content-Type: application/json

{
  "enabled": true,
  "settings": {
    "api_key": "your_visagov_api_key",
    "webhook_url": "https://your-domain.com/webhook"
  }
}

Health Check Examples

Ping

GET /api/health/ping HTTP/1.1
Host: capdata.es

Database Health

GET /api/health/database HTTP/1.1
Host: capdata.es

Response Examples

Successful Response

{
  "success": true,
  "data": {
    "id": 123,
    "message": "Operation completed successfully"
  },
  "timestamp": "2025-01-15T10:30:00Z"
}

Error Response

{
  "success": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "The provided API key is invalid",
    "details": "Please check your API key and try again"
  },
  "timestamp": "2025-01-15T10:30:00Z"
}
💡 Tip: Use the Postman Collection to test these examples with pre-configured requests and environments.
⚠️ Security Note: Always use HTTPS in production and never expose your API keys in client-side code.