Skip to content

Organizations API

Organizations API

Organizations represent the companies you are selling to (e.g., retail shops, business customers). Each organization belongs to your company and can have multiple contacts, deals, and related data.

Endpoints Overview

MethodEndpointDescription
GET/api-v1-organizationsList all organizations with filtering, sorting, and pagination
GET/api-v1-organizations/:idGet a single organization by ID
POST/api-v1-organizationsCreate a new organization
PATCH/api-v1-organizations/:idUpdate an existing organization
DELETE/api-v1-organizations/:idSoft delete an organization

Required Scopes

  • Read operations: read:organizations
  • Write operations: write:organizations

List Organizations

List all organizations with support for filtering, sorting, and pagination.

Endpoint: GET /api-v1-organizations

Scope: read:organizations

Query Parameters

Pagination

ParameterTypeDefaultDescription
limitinteger50Number of records per page (max: 100)
pageinteger1Page number for offset-based pagination
per_pageinteger50Alternative to limit for offset-based pagination
cursorstring-Cursor for cursor-based pagination

Filtering

Filters can be applied using the following syntax:

  • Simple equality: ?name=Acme Corp
  • With operator: ?name[like]=Acme or ?created_at[gte]=2024-01-01

Supported operators: eq, ne, gt, gte, lt, lte, like, in

Filterable fields:

  • name - Organization name (string)
  • status - Organization status (enum: lead, active, inactive, lost)
  • organization_type - Type of organization (string)
  • city - City location (string)
  • country - Country location (string)
  • created_at - Creation timestamp (ISO 8601)

Sorting

Use the sort parameter with field name. Prefix with - for descending order.

Examples:

  • ?sort=name - Sort by name ascending
  • ?sort=-created_at - Sort by creation date descending

Sortable fields: name, created_at, updated_at, status

Response

Returns a paginated list of organizations.

{
"data": [
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Acme Retail Shop",
"status": "active",
"organization_type": "retail",
"address": "123 Main St",
"city": "Berlin",
"state": "Berlin",
"postal_code": "10115",
"country": "Germany",
"domain": "acme-shop.de",
"metadata": {},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
],
"pagination": {
"total": 100,
"limit": 50,
"page": 1,
"per_page": 50,
"total_pages": 2,
"has_more": true
}
}

Example Request

Terminal window
curl -X GET "https://your-project.supabase.co/functions/v1/api-v1-organizations?limit=20&status=active&sort=-created_at" \
-H "Authorization: Bearer YOUR_API_KEY"

Get Single Organization

Retrieve a single organization by its unique ID.

Endpoint: GET /api-v1-organizations/:id

Scope: read:organizations

Path Parameters

ParameterTypeRequiredDescription
idUUIDYesOrganization ID

Response

Returns a single organization object.

{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Acme Retail Shop",
"status": "active",
"organization_type": "retail",
"address": "123 Main St",
"city": "Berlin",
"state": "Berlin",
"postal_code": "10115",
"country": "Germany",
"domain": "acme-shop.de",
"metadata": {},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
}

Example Request

Terminal window
curl -X GET "https://your-project.supabase.co/functions/v1/api-v1-organizations/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer YOUR_API_KEY"

Error Responses

404 Not Found:

{
"error": {
"code": "NOT_FOUND",
"message": "Organization not found"
}
}

Create Organization

Create a new organization in your CRM.

Endpoint: POST /api-v1-organizations

Scope: write:organizations

Request Body

FieldTypeRequiredDescription
namestringYesOrganization name (trimmed, non-empty)
statusenumNoStatus: lead, active, inactive, lost (default: lead)
organization_typestringNoType of organization (e.g., “retail”, “wholesale”)
addressstringNoStreet address
citystringNoCity
statestringNoState or region
postal_codestringNoPostal/ZIP code
countrystringNoCountry
domainstringNoWebsite domain
metadataobjectNoCustom metadata as JSON object

Response

Returns the created organization with a 201 Created status.

{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Acme Retail Shop",
"status": "lead",
"organization_type": "retail",
"address": "123 Main St",
"city": "Berlin",
"state": "Berlin",
"postal_code": "10115",
"country": "Germany",
"domain": "acme-shop.de",
"metadata": {},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
}

Example Request

Terminal window
curl -X POST "https://your-project.supabase.co/functions/v1/api-v1-organizations" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Retail Shop",
"status": "lead",
"organization_type": "retail",
"city": "Berlin",
"country": "Germany",
"domain": "acme-shop.de"
}'

Error Responses

400 Validation Error (missing name):

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Name is required",
"details": [
{
"field": "name",
"message": "Name is required"
}
]
}
}

400 Validation Error (invalid status):

{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid status. Must be one of: lead, active, inactive, lost",
"details": [
{
"field": "status",
"message": "Must be one of: lead, active, inactive, lost"
}
]
}
}

Update Organization

Update an existing organization. Only provided fields will be updated.

Endpoint: PATCH /api-v1-organizations/:id

Scope: write:organizations

Path Parameters

ParameterTypeRequiredDescription
idUUIDYesOrganization ID

Request Body

All fields are optional. Only include fields you want to update.

FieldTypeDescription
namestringOrganization name
statusenumStatus: lead, active, inactive, lost
organization_typestringType of organization
addressstringStreet address
citystringCity
statestringState or region
postal_codestringPostal/ZIP code
countrystringCountry
domainstringWebsite domain
metadataobjectCustom metadata (replaces existing)

Response

Returns the updated organization.

{
"data": {
"id": "123e4567-e89b-12d3-a456-426614174000",
"name": "Acme Retail Shop",
"status": "active",
"organization_type": "retail",
"address": "456 New Address",
"city": "Berlin",
"state": "Berlin",
"postal_code": "10115",
"country": "Germany",
"domain": "acme-shop.de",
"metadata": {},
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-16T14:20:00Z"
}
}

Example Request

Terminal window
curl -X PATCH "https://your-project.supabase.co/functions/v1/api-v1-organizations/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "active",
"address": "456 New Address"
}'

Error Responses

404 Not Found:

{
"error": {
"code": "NOT_FOUND",
"message": "Organization not found"
}
}

400 No Fields:

{
"error": {
"code": "INVALID_REQUEST",
"message": "No fields to update"
}
}

Delete Organization

Soft delete an organization. The organization is not permanently deleted but marked with a deleted_at timestamp and will no longer appear in API responses.

Endpoint: DELETE /api-v1-organizations/:id

Scope: write:organizations

Path Parameters

ParameterTypeRequiredDescription
idUUIDYesOrganization ID

Response

Returns a deletion confirmation.

{
"data": {
"deleted": true
}
}

Example Request

Terminal window
curl -X DELETE "https://your-project.supabase.co/functions/v1/api-v1-organizations/123e4567-e89b-12d3-a456-426614174000" \
-H "Authorization: Bearer YOUR_API_KEY"

Error Responses

404 Not Found:

{
"error": {
"code": "NOT_FOUND",
"message": "Organization not found"
}
}

Status Field

The status field represents the current relationship status with the organization:

ValueDescription
leadPotential customer, not yet qualified
activeActive customer with ongoing business
inactiveFormer customer or inactive account
lostLost opportunity, not a customer

Multi-Tenant Isolation

All organizations are automatically scoped to your company. You can only access organizations that belong to your company (determined by your API key’s company_id).


  • Contacts: Organizations can have multiple contacts. See Contacts API
  • Deals: Organizations can have multiple deals. See Deals API