Skip to content

Tutorial: Get Companies List

Use this endpoint to retrieve a list of all companies (ID and name) available in the database.
This is particularly useful when you need to find the correct client_company_id or vendor_company_id before creating or editing a contract.


Endpoint

GET /api/v1/companies

Authorization

This endpoint requires authentication and is available to admin users only.
Use the Bearer token from an authenticated session.

Request Headers

Authorization: Bearer <your_token_here>
Accept: application/json

Query Parameters

Parameter Type Required Description
search string No Filter companies by name (partial match, case-insensitive)

Example Requests

curl -X GET "https://your-domain.com/api/v1/companies" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json"
curl -X GET "https://your-domain.com/api/v1/companies?search=acme" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Accept: application/json"

Response

{
  "companies": [
    { "id": 1, "name": "Law" },
    { "id": 2, "name": "La" },
    { "id": 4, "name": "Justin" },
    { "id": 10, "name": "Chaw" }
  ]
}

Fields

Field Description
id Numeric company ID — use this as client_company_id or vendor_company_id in contract endpoints
name Company display name

Status Codes

Status Meaning Description
200 OK Company list returned successfully
401 Unauthorized Missing or invalid Bearer token
403 Forbidden Admin access required