Organization Endpoints
Manage organizations (tenants). Every organization represents a B2B customer entity with its own collaborators, entitlements, orders, and billing data.
Base path: /wp-json/middag-account/v1/organizations
Endpoints
| Method | Endpoint | Auth | Scope | Description |
|---|---|---|---|---|
| GET | /organizations | JWT | -- | List user's organizations |
| POST | /organizations | JWT | -- | Create new organization |
| GET | /organizations/{id} | JWT + Org | organization | Organization details |
| PUT | /organizations/{id} | JWT + Org | organization | Update organization |
| DELETE | /organizations/{id} | JWT + Org | organization (owner) | Delete organization |
| POST | /organizations/cnpj-check | JWT | -- | Validate CNPJ via federal API |
| GET | /organizations/{id}/collaborators | JWT + Org | organization | List organization members |
GET /organizations
List all organizations the authenticated user belongs to.
Response (200):
{
"success": true,
"data": [
{
"id": 42,
"name": "Acme Corp",
"legal_name": "Acme Corp Ltda",
"cnpj": "12.345.678/0001-90",
"status": "publish",
"verification_status": "verified",
"type": "company",
"owner_id": 15
}
],
"meta": {
"page": 1,
"per_page": 20,
"total": 1,
"pages": 1
}
}POST /organizations
Create a new organization. The authenticated user becomes the owner.
Request:
{
"name": "Acme Corp",
"legal_name": "Acme Corp Ltda",
"cnpj": "12.345.678/0001-90",
"email": "billing@example.com",
"phone": "+55 61 99999-0000",
"type": "company",
"address": "Rua Principal 100",
"city": "Brasilia",
"state": "DF",
"country": "BR",
"zipcode": "70000-000"
}Response (201):
{
"success": true,
"data": {
"id": 43,
"name": "Acme Corp",
"status": "publish",
"verification_status": "pending",
"owner_id": 15
},
"message": "Organization created"
}GET /organizations/:id
Retrieve full details for a single organization.
Headers: X-Middag-Organization: {id}
Response fields: id, name, legal_name, cnpj, state_registration, email, phone, address, address2, address_number, neighborhood, city, state, country, zipcode, ibge_code, type, status, verification_status, verified_at, owner_id, website, notes, requires_invoice_for_payment, created_at, updated_at.
PUT /organizations/:id
Update an organization. Only fields present in the request body are updated.
Headers: X-Middag-Organization: {id}
Request:
{
"phone": "+55 61 98888-0000",
"website": "https://example.com"
}DELETE /organizations/:id
Soft-delete an organization. Only the owner can perform this action.
Headers: X-Middag-Organization: {id}
Response (200):
{
"success": true,
"message": "Organization deleted"
}POST /organizations/cnpj-check
Validate a Brazilian CNPJ against the federal API (Receita Federal).
Request:
{
"cnpj": "12345678000190"
}Response (200):
{
"success": true,
"data": {
"valid": true,
"legal_name": "ACME CORP LTDA",
"status": "ATIVA"
}
}Filters (GET /organizations)
| Parameter | Type | Description |
|---|---|---|
search | string | Search by name or CNPJ |
status | string | Filter by status (publish, draft) |
type | string | Filter by type (company, individual) |
Related
- Collaborator Endpoints -- Manage organization members
- Core Concepts: Organizations