Companies API
The Companies API allows you to manage companies, company members, administrators, and invitations. You can create companies, manage membership, handle invitations, and transfer ownership.
Base URL
https://api.aloochat.ai/api/publicAuthentication
All requests require an API key in the x-api-key header:
x-api-key: your_api_key_hereEndpoints
Create Company
Create a new company.
Endpoint: POST /companies
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | Yes | Company name |
| industry | string | No | Company industry |
| contact_email | string | No | Contact email address |
| contact_phone | string | No | Contact phone number |
| address | string | No | Company address |
| website | string | No | Company website |
| working_hours | string | No | Working hours information |
Example Requests
curl -X POST "https://api.aloochat.ai/api/public/companies" \
-H "x-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corp",
"industry": "Technology",
"contact_email": "contact@acme.com",
"website": "https://acme.com"
}'List Companies
Get a list of companies accessible to the authenticated user.
Endpoint: GET /companies
Example Requests
curl -X GET "https://api.aloochat.ai/api/public/companies" \
-H "x-api-key: your_api_key_here"Get Current Company
Get the current active company for the authenticated user.
Endpoint: GET /companies/current
Example Requests
curl -X GET "https://api.aloochat.ai/api/public/companies/current" \
-H "x-api-key: your_api_key_here"Update Company
Update the current company information.
Endpoint: PUT /companies
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| name | string | No | Company name |
| industry | string | No | Company industry |
| contact_email | string | No | Contact email address |
| contact_phone | string | No | Contact phone number |
| address | string | No | Company address |
| website | string | No | Company website |
| working_hours | string | No | Working hours information |
Example Requests
curl -X PUT "https://api.aloochat.ai/api/public/companies" \
-H "x-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Corporation",
"industry": "Software Technology",
"contact_email": "info@acme.com"
}'Switch Active Company
Switch to a different company as the active company.
Endpoint: POST /companies/switch/{companyId}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| companyId | string (UUID) | Yes | The ID of the company to switch to |
Example Requests
curl -X POST "https://api.aloochat.ai/api/public/companies/switch/123e4567-e89b-12d3-a456-426614174000" \
-H "x-api-key: your_api_key_here"Company Members
Add Company Member
Add a new member to the company.
Endpoint: POST /companies/members
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| user_id | string (UUID) | Yes | User ID to add as member |
| role | string | No | Member role (default: “member”) |
Example Requests
curl -X POST "https://api.aloochat.ai/api/public/companies/members" \
-H "x-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"user_id": "123e4567-e89b-12d3-a456-426614174000",
"role": "developer"
}'List Company Members
Get a list of all company members.
Endpoint: GET /companies/members
Example Requests
curl -X GET "https://api.aloochat.ai/api/public/companies/members" \
-H "x-api-key: your_api_key_here"Remove Company Member
Remove a member from the company.
Endpoint: DELETE /companies/members/{memberId}
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| memberId | string (UUID) | Yes | The ID of the member to remove |
Example Requests
curl -X DELETE "https://api.aloochat.ai/api/public/companies/members/123e4567-e89b-12d3-a456-426614174000" \
-H "x-api-key: your_api_key_here"Company Administrators
Add Company Administrator
Add a new administrator to the company.
Endpoint: POST /companies/admins
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| user_id | string (UUID) | Yes | User ID to add as administrator |
Example Requests
curl -X POST "https://api.aloochat.ai/api/public/companies/admins" \
-H "x-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"user_id": "123e4567-e89b-12d3-a456-426614174000"
}'List Company Administrators
Get a list of all company administrators.
Endpoint: GET /companies/admins
Example Requests
curl -X GET "https://api.aloochat.ai/api/public/companies/admins" \
-H "x-api-key: your_api_key_here"Company Invitations
Create Company Invitation
Send an invitation to join the company.
Endpoint: POST /companies/invitations
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| string | Yes | Email address to send invitation to | |
| role | string | No | Role for the invited user (default: “member”) |
| message | string | No | Custom message to include in invitation |
Example Requests
curl -X POST "https://api.aloochat.ai/api/public/companies/invitations" \
-H "x-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"email": "newuser@example.com",
"role": "developer",
"message": "Welcome to our team!"
}'List Company Invitations
Get a list of all pending company invitations.
Endpoint: GET /companies/invitations
Example Requests
curl -X GET "https://api.aloochat.ai/api/public/companies/invitations" \
-H "x-api-key: your_api_key_here"Accept Company Invitation
Accept a company invitation using an invitation token.
Endpoint: POST /companies/invitations/accept
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| token | string | Yes | Invitation token received via email |
Example Requests
curl -X POST "https://api.aloochat.ai/api/public/companies/invitations/accept" \
-H "x-api-key: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"token": "invitation_token_here"
}'Response Examples
Company Object
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Acme Corp",
"industry": "Technology",
"contact_email": "contact@acme.com",
"contact_phone": "+1-555-0123",
"address": "123 Main St, San Francisco, CA 94105",
"website": "https://acme.com",
"working_hours": "9 AM - 5 PM PST",
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-20T14:45:00Z"
}Company Member Object
{
"id": "456e7890-e89b-12d3-a456-426614174000",
"user_id": "789e0123-e89b-12d3-a456-426614174000",
"company_id": "123e4567-e89b-12d3-a456-426614174000",
"role": "developer",
"joined_at": "2024-01-16T09:00:00Z",
"user": {
"id": "789e0123-e89b-12d3-a456-426614174000",
"email": "developer@example.com",
"first_name": "John",
"last_name": "Doe"
}
}Company Invitation Object
{
"id": "abc12345-e89b-12d3-a456-426614174000",
"email": "newuser@example.com",
"role": "developer",
"message": "Welcome to our team!",
"status": "pending",
"token": "invitation_token_here",
"expires_at": "2024-02-15T10:30:00Z",
"created_at": "2024-01-15T10:30:00Z"
}Error Responses
The API returns standard HTTP status codes and error messages:
- 400 Bad Request: Invalid request data
- 401 Unauthorized: Missing or invalid API key
- 403 Forbidden: Insufficient permissions
- 404 Not Found: Resource not found
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Server error
Example error response:
{
"detail": "Company not found",
"status_code": 404
}