Skip to content

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

MethodEndpointAuthScopeDescription
GET/organizationsJWT--List user's organizations
POST/organizationsJWT--Create new organization
GET/organizations/{id}JWT + OrgorganizationOrganization details
PUT/organizations/{id}JWT + OrgorganizationUpdate organization
DELETE/organizations/{id}JWT + Orgorganization (owner)Delete organization
POST/organizations/cnpj-checkJWT--Validate CNPJ via federal API
GET/organizations/{id}/collaboratorsJWT + OrgorganizationList organization members

GET /organizations

List all organizations the authenticated user belongs to.

Response (200):

json
{
    "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:

json
{
    "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):

json
{
    "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:

json
{
    "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):

json
{
    "success": true,
    "message": "Organization deleted"
}

POST /organizations/cnpj-check

Validate a Brazilian CNPJ against the federal API (Receita Federal).

Request:

json
{
    "cnpj": "12345678000190"
}

Response (200):

json
{
    "success": true,
    "data": {
        "valid": true,
        "legal_name": "ACME CORP LTDA",
        "status": "ATIVA"
    }
}

Filters (GET /organizations)

ParameterTypeDescription
searchstringSearch by name or CNPJ
statusstringFilter by status (publish, draft)
typestringFilter by type (company, individual)