Skip to main content

Organizations API

The Organizations API allows you to manage organization invitations and memberships.

Base URL

https://dreamsolve.ai/api/v1

Authentication

All endpoints require authentication via the x-api-key header. See the API Overview for details.


List Invitations

List all invitations for an organization.

GET /api/v1/organizations/:organizationId/invitations

Path Parameters

ParameterTypeDescription
organizationIdstringThe organization ID

Requirements

  • User must be a member of the organization

Response

{
"invitations": [
{
"id": "inv_123",
"invitee_email": "user@example.com",
"status": "pending",
"role_id": "role_456",
"created_at": "2024-01-15T10:00:00Z",
"expires_at": "2024-01-22T10:00:00Z"
}
]
}

Create Invitation

Create a new organization invitation.

POST /api/v1/organizations/:organizationId/invitations

Path Parameters

ParameterTypeDescription
organizationIdstringThe organization ID

Requirements

  • User must be an owner of the organization

Request Body

{
"inviteeEmail": "newuser@example.com",
"roleId": "role_456"
}
FieldTypeRequiredDescription
inviteeEmailstringYesEmail address of the person to invite
roleIdstringYesRole ID to assign to the invitee

Response

{
"invitation": {
"id": "inv_124",
"invitee_email": "newuser@example.com",
"status": "pending",
"role_id": "role_456",
"created_at": "2024-01-15T10:00:00Z",
"expires_at": "2024-01-22T10:00:00Z"
}
}

Status Code: 201 Created


Cancel Invitation

Cancel a pending invitation.

DELETE /api/v1/organizations/:organizationId/invitations/:invitationId

Path Parameters

ParameterTypeDescription
organizationIdstringThe organization ID
invitationIdstringThe invitation ID

Requirements

  • User must be an owner of the organization

Response

{
"message": "Invitation cancelled successfully"
}

Invitation Status Values

StatusDescription
pendingInvitation has been sent, awaiting acceptance
acceptedInvitation was accepted
expiredInvitation has expired
cancelledInvitation was cancelled

Organization Roles

Common organization roles:

RoleDescription
ownerFull administrative access
adminAdministrative access (cannot delete org)
memberStandard member access
viewerRead-only access

Error Responses

Status CodeDescription
400Bad Request - Missing required fields
401Unauthorized - Invalid or missing API key
403Forbidden - Insufficient permissions
404Not Found - Organization or invitation not found
500Internal Server Error

Example Error Responses

{
"error": "inviteeEmail is required"
}
{
"error": "Only organization owners can create invitations"
}
{
"error": "Failed to create invitation. You may not have permission, or the user may already be a member."
}

Example Usage

List organization invitations

curl -X GET \
-H "x-api-key: YOUR_API_KEY" \
https://dreamsolve.ai/api/v1/organizations/org_123/invitations

Invite a new member

curl -X POST \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"inviteeEmail": "colleague@example.com",
"roleId": "role_member"
}' \
https://dreamsolve.ai/api/v1/organizations/org_123/invitations