Aiten Integration API — Trip Management
This reference describes the REST API that lets ERP, WMS, or in-house systems create trips on Aiten, track trip status, and access proofs of delivery.
Base URL: https://api.aiten.io
Data format: JSON (Content-Type: application/json)
Versioning: Endpoints carry no version prefix (/api/...). Backward-incompatible changes are announced on this page and also communicated directly to integration owners.
Release note — 25 August 2026: The
company_idfield is now required inPOST /api/trips/requests made with a service key. Requests without this field are rejected with400. If your integration does not send this field, you need to update it.
Release note — 13 October 2026: Tenant security on the document record endpoints has been tightened. For calls made with customer scope (a dashboard account or a service identity bound to a company):
POST /api/stops/{stop_id}/documents/accepts onlys3_key,phase,doc_direction,doc_type, and the identity and party fields (waybill_number,ettn,waybill_date,sender_name,sender_vkn,receiver_name,receiver_vkn,delivery_address). If fields that the server fills in, such as signature, stamp, confidence, quantity, or paired document, are sent,400is returned.PATCHcorrects only the identity and party fields. A correction that changes a line of a waybill already finalized in reconciliation is rejected with409; the finalization must be reversed first. Thecompare,partial-delivery, andschedule-doc-review-reminderendpoints return403for a customer identity. On the customer detail endpoint (/api/customers/{ref}/), the old reference of an updated company record returns410; reopen it from the list.
Quick Start
1. Get credentials. For the integration, request a service key (X-WA-Service-Key) assigned to your company from the Aiten team.
2. Send your first request. The example below creates a test trip with two stops:
curl -X POST https://api.aiten.io/api/trips/ \
-H "X-WA-Service-Key: $AITEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"company_id": "<company-uuid>",
"driver_phone": "905551234567",
"driver_first_name": "Test",
"driver_last_name": "Driver",
"plate": "34 TEST 01",
"source": "API",
"yukleme_no": "TEST-0001",
"stops": [
{ "order": 1, "stop_type": "PICKUP", "location_name": "Test Warehouse", "expected_document_count": 1 },
{ "order": 2, "stop_type": "DELIVERY", "location_name": "Test Customer", "expected_document_count": 1 }
]
}'
3. Check the response. A 201 Created response with a trip_code (e.g. DL-260701-001) means the trip was created.
Important: A trip creation request sends a real WhatsApp notification to the number in the
driver_phonefield. Do not use a real driver's number when testing.
To track trip status, use the GET /api/trips/{trip_code}/ endpoint; to receive status changes in real time, you can set up webhook notifications.
Authentication
The API supports two authentication methods. The service key is the recommended method for server-to-server integrations.
Service key (recommended)
Add the following header to every request:
X-WA-Service-Key: <your-service-key>
The service key is static; it requires no login or token refresh. The key is issued specifically for your company by the Aiten team.
Security: Store the service key on the server side only. Using it in client-side environments such as a browser or mobile app is a security violation; if this is detected, the key is revoked and a new one is issued.
JWT (through a user account)
For scenarios that require user-level traceability, an integration-specific dashboard account is set up. Session flow:
# 1. Log in; get access and refresh tokens
curl -X POST https://api.aiten.io/api/token/ \
-H "Content-Type: application/json" \
-d '{"email": "integration@yourcompany.com", "password": "..."}'
# → { "access": "eyJ...", "refresh": "eyJ..." }
# 2. Use the access token in subsequent requests
curl https://api.aiten.io/api/trips/ \
-H "Authorization: Bearer eyJ..."
# 3. Refresh the access token when it expires (60 minutes)
curl -X POST https://api.aiten.io/api/token/refresh/ \
-H "Content-Type: application/json" \
-d '{"refresh": "eyJ..."}'
The refresh token is valid for 7 days; when it expires, you need to log in again with /api/token/.
Choosing a method
| Scenario | Recommended method |
|---|---|
| Server-to-server integration (ERP, WMS, scheduled jobs) | Service key |
| Actions on behalf of a user; flows where the actor must be traceable | JWT |
Security guarantees
- Authentication comparisons use methods that resist timing attacks (timing-safe). An undefined or empty key authenticates no request.
- Tenant isolation is enforced on the server side. An account can access only the trip, driver, and message records of its own company; requests for a resource belonging to another tenant are answered with
404so the resource's existence is not revealed. - Document key (
s3_key) fields go through format validation on the server side; values outside the allowed prefix are rejected. - All traffic is carried over HTTPS and protected with HSTS.
Rate limits
| Endpoint | Limit |
|---|---|
POST /api/token/ |
10 requests/minute per IP |
POST /api/token/refresh/ |
60 requests/minute per IP |
POST /api/register/, POST /api/contact-requests/ |
10 requests/hour per IP |
| Integration endpoints with a service key | No defined limit |
When a limit is exceeded, a 429 status code and a Retry-After header are returned. Although service key endpoints have no defined limit, we recommend keeping bulk submissions to a few requests per second.
Creating a Trip
POST /api/trips/
Content-Type: application/json
Request body
{
"company_id": "<company-uuid>",
"driver_phone": "905551234567",
"driver_first_name": "Ahmet",
"driver_last_name": "Yılmaz",
"plate": "34 ABC 123",
"trailer_plate": "34 XYZ 456",
"notes": "",
"yukleme_no": "ERP-2026-0001",
"source": "API",
"stops": [
{
"order": 1,
"stop_type": "PICKUP",
"location_name": "Factory - Adana",
"location_code": "",
"location_address": "...",
"location_latitude": null,
"location_longitude": null,
"contact_name": "",
"contact_phone": "",
"expected_document_count": 1,
"waybill_numbers": [],
"planned_arrival": null,
"notes": ""
}
]
}
Field reference — trip level
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
company_id |
UUID | Required with a service key | — | The company the trip is created for. Required in requests made with a service key; 400 is returned if it is missing. Ignored in requests made with a dashboard session; the trip is always created for the company the session belongs to. |
driver_phone |
string (≤20) | ✓ | — | The driver's phone number; used as the driver's identity on the platform. A driver record is created automatically for an unregistered number. |
driver_first_name |
string (≤150) | — | "" |
Used if the driver record is being created for the first time or the name is being updated. |
driver_last_name |
string (≤150) | — | "" |
The driver's last name. |
plate |
string (≤20) | ✓ | — | Tractor license plate. |
trailer_plate |
string (≤20) | — | "" |
Trailer license plate. |
notes |
string | — | "" |
Free-text note about the trip. |
yukleme_no |
string (≤100) | — | "" |
The order or load number in your source system. When it is filled in, the duplicate trip check applies; see Retry Safety. |
source |
enum | — | "MANUAL" |
MANUAL, EXCEL, or API. External integrations are expected to send "API"; dashboard reports break trips down by source. |
stops |
array | ✓ (at least 1) | — | List of stops. order values must be unique within the trip. |
Field reference — stop level
| Field | Type | Required | Description |
|---|---|---|---|
order |
int | ✓ | Stop sequence; starts at 1 and is unique within the trip. |
stop_type |
enum | ✓ | PICKUP (loading), DELIVERY (delivery), or BOTH (loading and delivery at the same stop). |
location_name |
string | ✓ | Stop name; shown in the dashboard and in messages sent to the driver. |
location_code |
string | — | The location code in your source system. Aiten does not process it; it is stored to make data matching easier and returned unchanged in responses. |
location_address |
string | — | Full address; sent to the driver over WhatsApp. |
location_latitude, location_longitude |
float | — | Coordinates; used in the map view and distance calculations. |
contact_name, contact_phone |
string | — | Contact details of the person in charge at the stop. |
expected_document_count |
int | — | Number of waybills expected at the stop (default 1). The stop cannot be completed until the expected number is reached. |
waybill_numbers |
array[string] | — | Waybill numbers, if known in advance. For information only; verification is based on the document the driver uploads. |
planned_arrival |
datetime (ISO 8601) | — | Planned arrival time; used as the reference for reminders and delay calculations. |
notes |
string | — | Stop-specific note; sent to the driver. |
Server-side processing
A trip creation request is processed on the server in the following order:
- The company is determined. With a dashboard session, the trip is created for the session's company. With a service key, the
company_idfield is used; if the field is missing, the request is rejected with400. - The driver record is resolved. The driver matching
driver_phoneis found; if there is no record, one is created automatically. No separate pre-registration step is needed for the driver. - The balance check is applied. For companies with billing enabled, if the driver has an unpaid balance, the request is rejected with
402and the trip is not created. - The duplicate check is run. If
yukleme_nois filled in and a trip with the same number is active or was created in the last 3 days (excluding cancelled ones), the request is rejected with409. - The active trip check is run. If the driver has another trip in progress, the request is not blocked; an informational
warningfield is added to the response. The driver's older trips that are still waiting to start are cancelled automatically. - The trip is created. A
trip_codein theDL-YYMMDD-XXXformat is generated, the stops are saved, and a WhatsApp notification is sent to the driver. An error while sending the notification does not affect the trip record.
Successful response — 201 Created
{
"id": "8f3e2c10-4a9b-4e77-9c1a-2b6d5e8f0a11",
"trip_code": "DL-260701-001",
"share_token": "b7a1c9e0-...",
"status": "CREATED",
"last_action": null,
"notes": "",
"yukleme_no": "ERP-2026-0001",
"created_via": "API",
"company": { "id": "...", "name": "Sample Manufacturer Inc." },
"company_name": "Sample Manufacturer Inc.",
"driver": { "id": "...", "phone": "905551234567", "name": "Ahmet Yılmaz" },
"driver_name": "Ahmet Yılmaz",
"driver_phone": "905551234567",
"plate": "34 ABC 123",
"trailer_plate": "34 XYZ 456",
"current_latitude": null,
"current_longitude": null,
"last_location_update": null,
"last_eta_update": null,
"created_at": "2026-07-01T09:15:32Z",
"completed_at": null,
"issues": [],
"open_issue_count": 0,
"stops": [
{
"id": "b1a2c3d4-...",
"order": 1,
"stop_type": "PICKUP",
"location_name": "Factory - Adana",
"status": "PENDING",
"expected_document_count": 1,
"waybill_numbers": [],
"planned_arrival": null,
"actual_arrival": null,
"actual_departure": null,
"documents": []
},
{
"id": "c2b3d4e5-...",
"order": 2,
"stop_type": "DELIVERY",
"location_name": "Warehouse - Ankara",
"status": "PENDING",
"expected_document_count": 1,
"waybill_numbers": [],
"planned_arrival": null,
"actual_arrival": null,
"actual_departure": null,
"documents": []
}
]
}
If the driver has another trip in progress, the response also includes this field:
{ "warning": "Bu sürücünün aktif seferi var: DL-260630-004" }
(The API returns this message in Turkish; it means "This driver has an active trip: DL-260630-004".)
Error responses
| Code | Condition | Example body |
|---|---|---|
400 |
The body could not be validated; company_id was not sent with a service key; the s3_key format is invalid |
{ "driver_phone": ["This field is required."] } |
401 |
Credentials missing or invalid | — |
402 |
The driver has an unpaid balance (only for companies with billing enabled) | { "error": "wallet_debt", "message": "...", "debt_amount": "50.00", "driver_phone": "905551234567" } |
403 |
Authenticated, but no permission on the resource | — |
404 |
Record not found or outside the access scope (including an incorrect company_id or an inactive company) |
{ "error": "Şirket bulunamadı." } (Turkish for "Company not found.") |
409 |
Duplicate trip with the same yukleme_no |
{ "error": "duplicate_yukleme_no", "message": "...", "existing_trip_code": "DL-260701-001", "yukleme_no": "ERP-2026-0001" } |
429 |
Rate limit exceeded | — |
Note: At very high concurrent request volumes, trip code generation can rarely collide and the request may result in
500. In that case, simply retry the request after a short wait; see Error Handling.
Other Endpoints
The endpoints below use the same base URL and authentication methods. All results are limited to the requester's company scope.
List trips: GET /api/trips/
| Parameter | Description |
|---|---|
status |
CREATED, DRIVER_NOTIFIED, IN_PROGRESS, ALL_STOPS_DONE, COMPLETED, FAILED, CANCELLED |
search |
Search by trip code, license plate, driver name, or phone |
source |
MANUAL, EXCEL, or API |
waybill |
Trips that contain the given waybill number or ETTN |
date_from, date_to |
YYYY-MM-DD; range by creation date |
loading_point |
Filter by loading point name |
page |
Page number; 20 records per page |
curl "https://api.aiten.io/api/trips/?status=IN_PROGRESS&page=1" \
-H "X-WA-Service-Key: $AITEN_API_KEY"
{
"count": 47,
"next": "https://api.aiten.io/api/trips/?page=2",
"previous": null,
"results": [ { "trip_code": "DL-260701-001", "...": "..." } ],
"stats": { "active": 12, "completed": 340, "total": 352 }
}
The stats field contains company-wide totals regardless of the filters applied.
Trip details: GET /api/trips/{trip_code}/
Returns the full representation of a single trip, including the list of stops and documents (the structure is the same as the trip creation response). Returns 404 when the trip is not found or is outside the access scope:
{ "error": "Sefer bulunamadı." }
(Turkish for "Trip not found.")
Update a trip: PATCH /api/trips/{trip_code}/
Only the fields sent are updated: driver_phone, driver_first_name, driver_last_name, plate, trailer_plate, notes. To change the driver, all three driver fields must be sent together.
curl -X PATCH https://api.aiten.io/api/trips/DL-260701-001/ \
-H "X-WA-Service-Key: $AITEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"notes": "Customer wants delivery after 14:00"}'
Trip stops: GET /api/trips/{trip_code}/stops/
Returns the trip's stops, including document information, directly as an array.
Complete a trip: POST /api/trips/{trip_code}/complete/
Takes no request body. The trip is set to COMPLETED and the completed_at field is filled in. Response: 200 and the current trip representation.
Cancel a trip: POST /api/trips/{trip_code}/cancel/
Takes no request body. The trip is set to CANCELLED; pending stops are marked SKIPPED. Returns 400 for a trip that is already completed or cancelled.
Update location: POST /api/trips/{trip_code}/location/
{ "latitude": 39.9208, "longitude": 32.8541 }
Response: {"status": "ok", "last_location_update": "2026-07-01T10:22:00Z"}. In the normal flow, location data is collected by the platform; if you have your own vehicle tracking system, you can also send it through this endpoint.
Report an issue: POST /api/trips/{trip_code}/issue/
{ "issue_type": "DAMAGE", "description": "Pallet received damaged", "stop_id": "b1a2c3d4-..." }
Response: 201 and the created issue record.
Proof of delivery: GET /api/trips/{trip_code}/proof/
After the trip is completed, returns the verified waybill images and comparison results (POD). Used for reconciliation and archiving integrations.
Stop documents: GET /api/stops/{stop_id}/documents/
Lists the waybill documents of a stop. Because the documents field in the trip details response contains the same data, you usually do not need this endpoint separately.
Document records and the s3_key rule
The s3_key field in POST /api/stops/{stop_id}/documents/ requests can be at most 512 characters and must start with the documents/ prefix; values containing .., a leading /, ://, or \\ are rejected with 400. In the normal flow, these keys are generated by the platform's document upload service; we do not recommend that integrations generate keys manually.
When writing documents with customer scope: A POST request sends only s3_key, phase (INITIAL or SIGNED), doc_direction, doc_type, and the identity/party fields. The signature and stamp status, reading confidence, quantities, license plate, and paired document link are filled in on the server by reading the document; sending these fields results in 400. PATCH corrects only the identity and party fields; each correction is stored together with who made it and when. VKN fields must be a 10-digit (tax number) or 11-digit (Turkish national ID number) string of digits: in a POST request, an invalid value leaves the field empty (the raw value is stored on the server); in a PATCH request, 400 is returned. A correction that affects a line already finalized in reconciliation returns 409.
Outbound Events (Webhook)
When a webhook URL is set up for your company, important trip status transitions are POSTed to that URL in real time. Integrations without a webhook can query the same events from the GET /api/trips/{trip_code}/events/ endpoint. Contact the Aiten team to set up the webhook URL and signing key.
Event types
| Event | When |
|---|---|
trip.started |
The driver started the trip |
stop.arrived |
The driver arrived at the stop |
stop.completed |
The stop was completed (with the number of accepted documents) |
document.accepted |
A waybill was accepted (waybill number, ETTN, signature/stamp status) |
trip.eta_updated |
The arrival estimate was updated |
trip.delayed |
The estimate exceeded the planned arrival by more than 30 minutes |
trip.issue |
An issue was reported (damage, address, waiting, refusal) |
trip.flagged |
A situation requiring operator intervention was flagged |
trip.completed |
The trip was completed (summary) |
Body and signature
{
"event": "stop.arrived",
"trip_code": "DL-260701-001",
"occurred_at": "2026-07-01T14:30:00+00:00",
"data": { "stop_id": "...", "order": 2, "location": "Warehouse - Ankara" }
}
Every request carries the event type in the X-Aiten-Event header. If a signing key is set up, the X-Aiten-Signature header contains the HMAC-SHA256 digest (hex) of the raw request body; verification should be mandatory on your server. Delivery is retried three times at increasing intervals on a non-2xx response; after the third attempt, the event is marked failed and can be read from the event history.
Event history: GET /api/trips/{trip_code}/events/
Returns the trip's events in chronological order (up to 500). Each row contains event, occurred_at, data, and the webhook delivery status (delivery_status: empty = no webhook set up, sent, pending, failed).
Error Handling
4xx responses indicate something in the request that needs to be fixed; 5xx responses indicate a temporary problem on the server side. For 5xx, the request can be retried with exponential backoff; before retrying, take the idempotency section below into account.
| Code | Meaning | Recommended action |
|---|---|---|
400 |
Missing or invalid field | Fix the request based on the field-level error messages in the response body. |
401 |
Authentication failed | Check the service key; if you use JWT, refresh the token and log in again if needed. |
402 |
The driver has an unpaid balance | Retrying will not help; the trip cannot be created until the balance is settled. |
403 |
No permission | Confirm that the credentials are assigned to the correct company. |
404 |
Record not found | Check the identifier (trip_code, id); retrying will not help. |
409 |
Duplicate record | Use the existing_trip_code value in the response; do not retry the request. |
429 |
Rate limit exceeded | Wait for the time given in the Retry-After header. |
5xx |
Server-side problem | Retry a limited number of times with exponential backoff; if the problem persists, notify the support team. |
Retry Safety (Idempotency)
The API does not offer a separate idempotency key mechanism; retry safety is provided through the yukleme_no field:
- Assign a unique
yukleme_noto each order in your source system and send it in every trip creation request. - Treat a
409 duplicate_yukleme_noresponse not as an error but as confirmation that the operation was already completed;existing_trip_codein the response points to the existing trip. - The duplicate check does not run for requests without
yukleme_no. A retry after a network timeout can cause the same trip to be created twice. For this reason, usingyukleme_nois strongly recommended for external integrations.
Frequently Asked Questions
Is the API accessible over the internet?
Yes. api.aiten.io is open to the public internet. All endpoints that require authentication return 401 to requests without valid credentials.
Is there a test or sandbox environment?
There is no separate test environment; the only environment is api.aiten.io. When testing, we recommend using a phone number that is not real and a company account set up for testing.
Is an automatic notification (webhook) sent when trip status changes?
Yes. When a webhook URL is set up for your company, status transitions (trip.started, stop.arrived, document.accepted, etc.) are sent to your URL with an HMAC signature; see Outbound Events. Integrations without a webhook can query the same events through GET /api/trips/{trip_code}/events/.
How is the driver notified when a trip is created? When a trip is created successfully, the driver receives a WhatsApp notification with the trip summary and stop details. No app installation is needed on the driver's side; waybill photos are also sent over WhatsApp.
What happens if the same order is sent twice?
If yukleme_no was sent, the second request is rejected with 409 and the response contains the existing trip code. If yukleme_no was not sent, no duplicate check is applied and two separate trips are created.
Can we get support during integration? Yes. Throughout the integration, you can reach the Aiten team at merhaba@aiten.io with your technical questions.
