Skip to main content
GET
/
api
/
organizations
curl -X GET https://your-domain.com/api/organizations \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "items": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Acme Forest Corp",
      "rif": "J-123456789",
      "countryId": "660e8400-e29b-41d4-a716-446655440001",
      "createdAt": "2024-01-15T08:30:00.000Z"
    },
    {
      "id": "770e8400-e29b-41d4-a716-446655440002",
      "name": "Green Timber Industries",
      "rif": "J-987654321",
      "countryId": "660e8400-e29b-41d4-a716-446655440001",
      "createdAt": "2024-02-20T14:45:00.000Z"
    }
  ]
}

Overview

Returns a list of all organizations that the authenticated user has access to. Access is determined by user role and permissions:
  • SUPER_ADMIN: Can view all organizations
  • ADMIN: Can only view their own organization
  • Other roles: Require explicit READ permission on the organizations module

Authentication

This endpoint requires authentication. Include a valid session token in your request.
Scoped administrators (ADMIN role) will only see their own organization in the response.

Response

Returns an object containing an array of organization items.
items
array
Array of organization objects
curl -X GET https://your-domain.com/api/organizations \
  -H "Authorization: Bearer YOUR_TOKEN"
{
  "items": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Acme Forest Corp",
      "rif": "J-123456789",
      "countryId": "660e8400-e29b-41d4-a716-446655440001",
      "createdAt": "2024-01-15T08:30:00.000Z"
    },
    {
      "id": "770e8400-e29b-41d4-a716-446655440002",
      "name": "Green Timber Industries",
      "rif": "J-987654321",
      "countryId": "660e8400-e29b-41d4-a716-446655440001",
      "createdAt": "2024-02-20T14:45:00.000Z"
    }
  ]
}

Permissions

This endpoint checks permissions in the following order:
  1. Role-based access: SUPER_ADMIN and ADMIN roles have automatic access
  2. Permission-based access: Users without admin roles must have the organizations:READ permission

Filtering

The endpoint automatically filters results based on user role:
  • SUPER_ADMIN: Returns all active organizations
  • ADMIN (scoped): Returns only the organization the user belongs to
  • Other users: Returns all organizations (if they have the required permission)
All queries exclude soft-deleted organizations (where deletedAt is not null).

Implementation Details

The response includes the country relationship via Prisma’s include clause. Organizations are ordered by creation date in descending order (newest first). The rif field is extracted from the organization’s settings JSON field.

Build docs developers (and LLMs) love