Create Agency
Create a new agency under a partner.
WARNING
Requires agencies.create permission.
Endpoint
INFO
POST /api/v1/dashboard/agencies
Headers
| Header | Value | Required |
|---|---|---|
Content-Type | application/json | Yes |
Accept | application/json | Yes |
Authorization | Bearer {token} | Yes |
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
partner_id | integer | Yes | Parent partner ID |
name | string | Yes | Agency name |
code | string | Yes | Unique agency code |
email | string | Yes | Contact email |
phone | string | No | Contact phone |
address | string | No | Physical address |
latitude | decimal | No | Location latitude |
longitude | decimal | No | Location longitude |
timezone | string | No | Agency timezone |
Example Request
bash
curl -X POST https://api.daakey.com/api/v1/dashboard/agencies \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer {token}" \
-d '{
"partner_id": 1,
"name": "Midtown Branch",
"code": "ACME-MT",
"email": "midtown@acme.com",
"phone": "+1234567892",
"address": "789 Midtown Ave",
"latitude": 40.7549,
"longitude": -73.9840,
"timezone": "America/New_York"
}'Response
Success (201)
json
{
"success": true,
"message": "Agency created successfully",
"data": {
"id": 3,
"name": "Midtown Branch",
"code": "ACME-MT",
"partner": {
"id": 1,
"name": "Acme Car Rentals"
},
"email": "midtown@acme.com",
"phone": "+1234567892",
"address": "789 Midtown Ave",
"location": {
"latitude": 40.7549,
"longitude": -73.9840
},
"timezone": "America/New_York",
"status": "active",
"secret_key": "sk_live_xxxxxxxxxxxxxxxxxxxx",
"created_at": "2024-01-20T00:00:00Z"
},
"request_id": "uuid",
"timestamp": "2024-01-01T00:00:00.000Z"
}Error (422)
json
{
"success": false,
"message": "Validation failed",
"errors": {
"code": ["The code has already been taken."],
"partner_id": ["The selected partner is invalid."]
},
"data": null,
"request_id": "uuid",
"timestamp": "2024-01-01T00:00:00.000Z"
}Notes
- Agency code must be unique across the system
- A secret key is generated automatically for API authentication
- The secret key is only shown once - save it securely
- Use the secret key to generate agency signatures for the Client API