Skip to content

Create Agency

Create a new agency under a partner.

WARNING

Requires agencies.create permission.

Endpoint

INFO

POST /api/v1/dashboard/agencies

Headers

HeaderValueRequired
Content-Typeapplication/jsonYes
Acceptapplication/jsonYes
AuthorizationBearer {token}Yes

Request Body

ParameterTypeRequiredDescription
partner_idintegerYesParent partner ID
namestringYesAgency name
codestringYesUnique agency code
emailstringYesContact email
phonestringNoContact phone
addressstringNoPhysical address
latitudedecimalNoLocation latitude
longitudedecimalNoLocation longitude
timezonestringNoAgency 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

Daakey Car Sharing Platform