Skip to the article

CloselineAPI reference

API reference

Every route the Closeline API serves, who may call it, and how sign-in, workspaces, permissions, errors, lists and limits work.

For the Full Stack package

Base URL and response format

Every route is served under the /api prefix. Locally the base URL is http://localhost:8000/api. On a server it is your API's address followed by /api, the same value both frontends read from NEXT_PUBLIC_API_BASE_URL (Environment variables). Files are served outside the prefix, at /media.

Request bodies are JSON, except file uploads. Every answer comes in the same envelope:

Envelope
{
  "success": true,
  "data": { },
  "message": ""
}

Money is integer cents in every answer, and in a workspace's revenueTarget both ways: 8000000 is 80,000. Only a deal's value is sent in whole units, on POST and PATCH .../deals and on .../close: 12000 is 12,000. Text kept in two languages (deal names, stage names, activity titles, role names) is { "en": "…", "ar": "…" }.

The health check needs no token:

Terminal
curl http://localhost:8000/api/health
Response
{"success":true,"data":{"status":"ok","database":"up"},"message":""}

Until the database answers and holds its tables, it answers 503 with "status":"unavailable" and "database":"down". The Docker image's health check reads it.

Errors

A failure keeps the envelope, with success: false and the HTTP status:

Error
{
  "success": false,
  "data": null,
  "message": "deal_version_conflict",
  "errors": { "email": ["…"] }
}
StatusMeaning
400Invalid input; errors lists the messages per field
401Not signed in
403Not allowed: the role lacks the permission, sign-ups are closed, or the workspace's plan does not include the feature (plan_upgrade_required)
404Not found, not a member of the workspace, or someone else's record under an own-records grant
409A conflict, such as a stale deal version
429Too many attempts from one address
503Maintenance mode, for anyone who is not platform staff

When the API has a sentence for the error (a refused sign-in, a 429, sign-ups closed, maintenance mode, a feature the plan does not include), the message is that sentence in the request's language. A 401, 403 or 404 otherwise answers the general sentence for its status, and any other error answers its code for the client to word: deal_version_conflict, loss_reason_required, expected_close_required, contact_email_exists, last_admin.

Lists and paging

Paged lists (deals in the list and closed views, contacts, companies, activities, projects, the installation's users, staff and settings) take page and limit, at most 100 rows a page, and answer:

data
{ "data": [ ], "total": 62, "page": 1, "limit": 25, "totalPages": 3 }

Unless the caller sorts, or the view has an order of its own, rows come newest updated first. A collection that belongs to one workspace and is shown whole (the board, a deal's timeline, notes and files, members, invitations, roles, stages) answers without paging.

Language

Send Accept-Language: ar for Arabic messages; anything else answers in English. Records kept in two languages carry both whatever the header says, and the client picks one.

Signing in

  1. Sign in

    Terminal
    curl -X POST http://localhost:8000/api/auth/login \
      -H "Content-Type: application/json" \
      -d '{"email":"demo@closeline.example","password":"CloselineDemo!2026"}'

    data.access_token is the token, with token_type Bearer, expires_in (7d by default, JWT_EXPIRATION) and admin, the account with its platform access and workspaces. GET /api/auth/me answers the same account later.

  2. Call a workspace route

    Workspace routes take the workspace's public id, such as ws-studio-sales, from GET /api/workspaces.

    Terminal
    curl http://localhost:8000/api/workspaces/ws-studio-sales/deals -H "Authorization: Bearer YOUR_TOKEN"
  • An unknown email and a wrong password both answer 401 with the same message.
  • Ten failed sign-ins from one address within 15 minutes answer 429 until the oldest failure is 15 minutes old (RATE_LIMIT_LOGIN). Successful sign-ins are not counted.
  • While maintenance mode is on, a correct sign-in by an account that is not platform staff answers 503.
  • Tokens are stateless: signing out is the client forgetting its token.
MethodPathWho can call itWhat it does
POST/api/auth/loginAnyoneSign in: email, password
POST/api/auth/signupAnyoneA new account and a workspace of its own, signed in: name, email, password (8 to 128 characters), workspace, and optionally plan (starter, team, scale) and billing (monthly, yearly). 403 while sign-ups are closed
POST/api/auth/forgot-passwordAnyoneEmail a reset link: email, optionally locale, the email's language when the account chose none. Always answers { sent: true }
POST/api/auth/reset-passwordAnyoneFinish a reset: token, password. A link works once, within an hour
POST/api/auth/logoutAnyoneAnswers { signedOut: true }
GET/api/auth/meAny signed-in accountThe account, its platform access and its workspaces
PATCH/api/auth/meAny signed-in accountEdit firstName, lastName, email, phone
PATCH/api/auth/me/preferencesAny signed-in accounttheme (system, light, dark), reducedMotion, locale (en, ar), lastWorkspaceId
PATCH/api/admins/profile/passwordAny signed-in accountChange your own password: current_password, password, password_confirmation
GET/api/public-settingsAnyonemaintenanceMode and trialDays

Workspaces and permissions

Every CRM record belongs to a workspace, and its routes are /api/workspaces/:workspaceId/... with the workspace's public id. Each request checks that the caller is a member (otherwise 404) and holds the permission the route names, plainly or as its own-records variant (otherwise 403).

ResourceActions
deals, contacts, activities, reports, projectsview, create, edit, delete, view-own, edit-own
ai-assistant, team-members, workspace-settings, rolesview, create, edit, delete
billingview, edit

A permission is <resource>.<action>, such as deals.view. With view-own or edit-own, lists, totals, reports and search hold only the caller's records, and anyone else's answers 404. Admin holds every permission and cannot be edited; a caller grants only what it holds itself, and the last Admin cannot be moved to another role.

Platform permissions are separate and belong to the installation's staff: users.*, admins.*, roles.* and settings.*. The seeded Platform admin role holds all of them; Support reads users, staff, roles and settings.

Each workspace has its own clock: the sample workspace is read on Monday 21 September 2026 08:00 UTC, every other one on the real clock. GET /api/workspaces/:workspaceId answers it as clock.

Workspaces, team and roles

MethodPathWho can call itWhat it does
GET/api/workspacesAny signed-in accountThe caller's workspaces
GET/api/workspaces/:workspaceIdA member of the workspaceThe workspace, its plan, clock and settings
PATCH/api/workspaces/:workspaceIdMembers with workspace-settings.editname, website, description, currency, timeZone, locale and revenueTarget, the monthly target in integer cents. Only Admin holds the permission by default
GET/api/workspaces/:workspaceId/stagesA member of the workspaceThe pipeline stages
PUT/api/workspaces/:workspaceId/stagesMembers with workspace-settings.editReplace the stages; moveTo names where a removed stage's deals go
GET/api/workspaces/:workspaceId/membersA member of the workspaceThe members with their roles
PATCH/api/workspaces/:workspaceId/members/:memberIdMembers with roles.editChange a member's role
DELETE/api/workspaces/:workspaceId/members/:memberIdMembers with team-members.deleteRemove a member
GET/api/workspaces/:workspaceId/invitationsMembers with team-members.viewPending invitations
POST/api/workspaces/:workspaceId/invitationsMembers with team-members.createInvite by email with a role; the link works for seven days
POST/api/workspaces/:workspaceId/invitations/:id/resendMembers with team-members.createSend the invitation again
DELETE/api/workspaces/:workspaceId/invitations/:idMembers with team-members.createCancel an invitation
GET/api/invitations/:tokenAnyoneWhat an invitation link is for
POST/api/invitations/:token/acceptAny signed-in accountJoin the workspace
GET/api/workspaces/:workspaceId/rolesMembers with team-members.viewThe roles and their grants
GET/api/workspaces/:workspaceId/roles/changesMembers with team-members.viewRecent role changes
POST/api/workspaces/:workspaceId/rolesMembers with roles.createA new role, on the Scale plan
PUT/api/workspaces/:workspaceId/roles/:keyMembers with roles.editRename a role or change its grants; a change of grants needs the Team or Scale plan
DELETE/api/workspaces/:workspaceId/roles/:keyMembers with roles.deleteDelete a custom role

A workspace that is past due beyond its grace days cannot invite people until a plan is paid.

Deals

MethodPathWho can call itWhat it does
GET/api/workspaces/:workspaceId/dealsMembers with deals.viewThe board, by stage. ?view=list for the list with its filters; ?status=won, lost, closed or archived for closed deals
POST/api/workspaces/:workspaceId/dealsMembers with deals.createA new deal: name, value (whole units), stage, ownerId, optionally the company, contact, expectedClose, probability, source, priority and a first nextStep
GET/api/workspaces/:workspaceId/deals/:idMembers with deals.viewOne deal
PATCH/api/workspaces/:workspaceId/deals/:idMembers with deals.editEdit a deal; a stale version answers 409
POST/api/workspaces/:workspaceId/deals/:id/moveMembers with deals.editMove to stage; useDefault takes the stage's odds; version guards a stale board
POST/api/workspaces/:workspaceId/deals/:id/closeMembers with deals.editoutcome won (with closedOn and value) or lost (with reason)
POST/api/workspaces/:workspaceId/deals/:id/archiveMembers with deals.deleteTake it off the pipeline
POST/api/workspaces/:workspaceId/deals/:id/restoreMembers with deals.deleteBring it back
POST/api/workspaces/:workspaceId/deals/:id/link-projectMembers with deals.edit and projects.createLink projectId, or create a new project for it
GET/api/workspaces/:workspaceId/deals/:id/timelineMembers with deals.viewThe deal's timeline
GET/api/workspaces/:workspaceId/deals/:id/notesMembers with deals.viewThe deal's notes
POST/api/workspaces/:workspaceId/notesMembers with deals.viewA note on a deal (dealId) or a contact (contactId): body, up to 5,000 characters
GET/api/workspaces/:workspaceId/deals/:id/filesMembers with deals.viewThe deal's files
POST/api/workspaces/:workspaceId/deals/:id/filesMembers with deals.editAttach a file (multipart file, up to 10 MB)
GET/api/workspaces/:workspaceId/deals/:id/files/:fileId/downloadMembers with deals.viewDownload a file

Contacts, companies and activities

MethodPathWho can call itWhat it does
GET/api/workspaces/:workspaceId/companiesMembers with contacts.viewThe companies
POST/api/workspaces/:workspaceId/companiesMembers with contacts.createA new company
PATCH/api/workspaces/:workspaceId/companies/:idMembers with contacts.editEdit a company
GET/api/workspaces/:workspaceId/contactsMembers with contacts.viewThe contacts, with search, filters and paging
GET/api/workspaces/:workspaceId/contacts/exportMembers with contacts.viewThe filtered contacts as CSV
POST/api/workspaces/:workspaceId/contactsMembers with contacts.createA new contact; an email already in the workspace answers contact_email_exists
POST/api/workspaces/:workspaceId/contacts/bulkMembers with contacts.editids with action assign (with ownerId), archive or restore
POST/api/workspaces/:workspaceId/contacts/import/previewMembers with contacts.createUpload a CSV (multipart file, up to 2 MB and 500 rows); answers the columns, a first mapping and the checked rows
POST/api/workspaces/:workspaceId/contacts/import/:importId/mapMembers with contacts.createChange the mapping of fields to columns
POST/api/workspaces/:workspaceId/contacts/import/:importId/commitMembers with contacts.createWrite the rows; duplicates skip or update
GET/api/workspaces/:workspaceId/contacts/:idMembers with contacts.viewOne contact, with their deals, timeline and notes
PATCH/api/workspaces/:workspaceId/contacts/:idMembers with contacts.editEdit a contact
GET/api/workspaces/:workspaceId/activitiesMembers with activities.viewA week of activities; ?view=list for the paged list
POST/api/workspaces/:workspaceId/activitiesMembers with activities.createA new activity: title, type (call, meeting, task, email), the deal, contact, owner and times; status: "done" logs one that already happened
GET/api/workspaces/:workspaceId/activities/:idMembers with activities.viewOne activity
PATCH/api/workspaces/:workspaceId/activities/:idMembers with activities.editEdit, complete, reopen or reschedule
DELETE/api/workspaces/:workspaceId/activities/:idMembers with activities.deleteRemove an activity

An import is kept for an hour; nothing is written before the commit.

Overview, reports, search and the bell

MethodPathWho can call itWhat it does
GET/api/workspaces/:workspaceId/overviewMembers with deals.viewThe overview for ?period=month, quarter or year
GET/api/workspaces/:workspaceId/reportsMembers with reports.viewThe report for ?from= and to= (days)
GET/api/workspaces/:workspaceId/reports/exportMembers with reports.viewThe report as CSV
GET/api/workspaces/:workspaceId/reports/closed-deals/exportMembers with reports.viewEvery won and lost deal the caller may see as CSV, newest close first; from and to narrow it by close date. The Export CSV button on Won & lost deals
GET/api/workspaces/:workspaceId/searchA member of the workspaceDeals, contacts and companies for ?q= (two characters or more), within the caller's grants
GET/api/workspaces/:workspaceId/notificationsA member of the workspaceWhat changed since the caller's last look, as their role may see it
POST/api/workspaces/:workspaceId/notifications/readA member of the workspaceMark them read

Billing

MethodPathWho can call itWhat it does
GET/api/workspaces/:workspaceId/billingMembers with billing.viewThe plan, its status, the users, the next charge and the plans with their prices and features
GET/api/workspaces/:workspaceId/billing/invoicesMembers with billing.viewThe invoices
GET/api/workspaces/:workspaceId/billing/invoices/:invoiceId/download-linkMembers with billing.viewA signed link to the invoice's PDF, valid five minutes
POST/api/workspaces/:workspaceId/billing/previewMembers with billing.editWhat a plan change costs now and at each renewal
POST/api/workspaces/:workspaceId/billing/checkoutMembers with billing.editStart a payment or a plan change; answers the checkout address
POST/api/workspaces/:workspaceId/billing/checkout/:sessionId/syncMembers with billing.viewConfirm a returning checkout with the provider
POST/api/workspaces/:workspaceId/billing/keep-planMembers with billing.editTake back a change scheduled for the renewal
POST/api/workspaces/:workspaceId/billing/portalMembers with billing.editStripe's customer portal address
POST/api/workspaces/:workspaceId/billing/cancelMembers with billing.editCancel at the end of the period
POST/api/workspaces/:workspaceId/billing/resumeMembers with billing.editUndo a cancellation
GET/api/billing/invoices/download?token=Anyone with a signed linkThe invoice PDF
POST/api/billing/webhooks/stripeStripe, signed with STRIPE_WEBHOOK_SECRETPayments, renewals, failed payments and ended subscriptions
GET/api/billing/simulator/:sessionIdAny signed-in accountA test checkout session
POST/api/billing/simulator/:sessionId/completeAny signed-in accountComplete the test payment
POST/api/billing/simulator/:sessionId/cancelAny signed-in accountCancel the test payment

What each plan includes

Four features depend on the workspace's plan. A request for one the plan does not include answers 403 in the usual envelope, with a stable code, the feature and the smallest plan that has it, and a message in the request's language:

Error
{
  "success": false,
  "data": { "feature": "customRoles", "plan": "scale" },
  "message": "Custom roles are on the Scale plan.",
  "code": "plan_upgrade_required"
}
FeaturePlansWithout it
forecastTeam, ScaleGET .../overview and GET .../reports answer every forecast figure as null (forecast, priorForecast, forecastGrowth, each stage's and each owner's forecast), and GET .../reports/export leaves out the forecast lines. Nothing is refused
assistantTeam, ScaleThe assistant's routes answer plan_upgrade_required before any model or record is read
rolePermissionsTeam, ScalePUT .../roles/:key with permissions answers plan_upgrade_required; a rename without permissions works on every plan
customRolesScalePOST .../roles answers plan_upgrade_required
  • The plan is the workspace's own in every billing state: a trial has the plan it chose, and a past-due, ending or canceled workspace keeps its plan's features. A move to a smaller plan scheduled for the renewal changes nothing until the renewal.
  • A smaller plan deletes nothing: custom roles stay assigned, their grants keep working, and they can still be deleted.
  • GET /api/workspaces/:workspaceId answers what the plan includes as plan.features and the smallest plan with each feature as plan.featurePlans; GET .../billing gives each plan its features.
  • The checks are in the services that do the work (PlanGateService), so the dashboard, the assistant and the MCP tools meet the same one.

Projects and tasks

MethodPathWho can call itWhat it does
GET/api/workspaces/:workspaceId/projectsMembers with projects.viewThe projects, paged
GET/api/workspaces/:workspaceId/projects/archivedMembers with projects.viewThe archived projects
GET/api/workspaces/:workspaceId/projects/ownersMembers with projects.viewWho can own a project
POST/api/workspaces/:workspaceId/projectsMembers with projects.createA new project
GET/api/workspaces/:workspaceId/projects/:projectIdMembers with projects.viewOne project
PATCH/api/workspaces/:workspaceId/projects/:projectIdMembers with projects.editEdit a project
DELETE/api/workspaces/:workspaceId/projects/:projectIdMembers with projects.deleteArchive a project
POST/api/workspaces/:workspaceId/projects/:projectId/restoreMembers with projects.deleteRestore it
GET/api/workspaces/:workspaceId/projects/:projectId/activityMembers with projects.viewThe project's history
GET/api/workspaces/:workspaceId/projects/:projectId/tasksMembers with projects.viewIts tasks
POST/api/workspaces/:workspaceId/projects/:projectId/tasksMembers with projects.editA new task
PATCH/api/workspaces/:workspaceId/tasks/:taskIdMembers with projects.editEdit a task
POST/api/workspaces/:workspaceId/tasks/:taskId/moveMembers with projects.editMove a task to another column or position
DELETE/api/workspaces/:workspaceId/tasks/:taskIdMembers with projects.editRemove a task
GET/api/workspaces/:workspaceId/projects/:projectId/filesMembers with projects.viewIts files
POST/api/workspaces/:workspaceId/projects/:projectId/filesMembers with projects.editUpload a file (multipart file, up to 10 MB)
GET/api/workspaces/:workspaceId/projects/:projectId/files/:fileId/downloadMembers with projects.viewDownload a file

The installation: users, staff, roles and settings

MethodPathWho can call itWhat it does
GET/api/usersPlatform staff with users.viewEvery account, with its workspaces and platform role
GET/api/users/deletedPlatform staff with users.viewDeleted accounts
GET/api/users/statisticPlatform staff with users.viewCounts for the users pages
GET/api/users/:usernamePlatform staff with users.viewOne account
GET/api/users/deleted/:usernamePlatform staff with users.viewOne deleted account
POST/api/usersPlatform staff with users.createCreate an account
PATCH/api/users/:usernamePlatform staff with users.updateEdit an account
PATCH/api/users/:username/change-passwordPlatform staff with users.updateSet its password
DELETE/api/users/:usernamePlatform staff with users.deleteDelete it; the only Admin of a workspace is refused
POST/api/users/deleted/:username/restorePlatform staff with users.restoreRestore it
GET/api/adminsPlatform staff with admins.viewThe platform staff
GET/api/admins/statisticsPlatform staff with admins.viewCounts
GET/api/admins/:idPlatform staff with admins.viewOne staff member
POST/api/adminsPlatform staff with admins.createAdd a staff account
PATCH/api/admins/:idPlatform staff with admins.editEdit a staff account
PATCH/api/admins/profilePlatform staff with admins.editEdit your own staff profile, picture included
PATCH/api/admins/:id/rolesPlatform staff with admins.assign_rolesGrant platform roles
DELETE/api/admins/:idPlatform staff with admins.deleteRemove a staff account
GET/api/rolesPlatform staff with roles.viewThe platform roles
GET/api/roles/statisticsPlatform staff with roles.viewCounts
GET/api/roles/selectPlatform staff with roles.viewThe roles as options
GET/api/roles/permissionsPlatform staff with roles.viewEvery platform permission
GET/api/roles/:idPlatform staff with roles.viewOne role
POST/api/rolesPlatform staff with roles.createAdd a platform role
PUT/api/roles/:idPlatform staff with roles.editRename it
POST/api/roles/:id/permissionsPlatform staff with roles.assign_permissionsChoose its permissions
DELETE/api/roles/:idPlatform staff with roles.deleteDelete it
GET/api/settingsPlatform staff with settings.viewThe platform settings
GET/api/settings/:keyPlatform staff with settings.viewOne setting
PATCH/api/settings/:keyPlatform staff with settings.editChange it: { "value": "…" }
DELETE/api/settings/:keyPlatform staff with settings.editDelete it

The dashboard's users pages use the users routes. The staff, platform roles and settings routes have no page: a Platform admin calls them with their token, and an account's page under Users shows its PATCH /api/admins/:id/roles route.

  • POST /api/admins takes first_name, last_name, email, password and password_confirmation; PATCH /api/admins/:id changes those and phone; PATCH /api/admins/profile changes your own.
  • PATCH /api/admins/:id/roles takes { "role_ids": [2] }, with the ids from GET /api/roles/select; [] removes every platform role. DELETE /api/admins/:id is refused while the account is the last Admin of a workspace.
  • POST /api/roles takes { "name": "Billing desk" }, and POST /api/roles/:id/permissions the full list the role holds afterwards, { "permissions": ["users.view"] }. A role that an account holds cannot be deleted.
  • A caller grants only roles and permissions it holds itself.
  • PATCH /api/settings/:key takes the value as text, numbers and switches included, and applies to the next request.

The contact form and uploads

MethodPathWho can call itWhat it does
POST/api/contactAnyoneThe website's contact form: name, email, optional company, message, a one-time clientToken that makes a retry safe, and a hidden website field only bots fill in
POST/api/helpers/uploadAny signed-in accountUpload a picture (multipart file, up to 10 MB), with path and the size preset for; answers each stored size's address

Limits per address

RouteLimit
POST /api/auth/login10 failed sign-ins per 15 minutes (RATE_LIMIT_LOGIN)
POST /api/auth/signup10 per hour
POST /api/auth/forgot-password5 per 15 minutes
POST /api/auth/reset-password10 per 15 minutes
POST /api/contact5 per hour

A request over a limit answers 429. The counts live in the API's memory, so a restart clears them. Behind a reverse proxy, set TRUST_PROXY so each visitor is counted on their own address.

The assistant and its conversations

Included with your purchase. Sign in to read, or open it in your download.

The assistant's streaming route, its model list, openers, proposals and the saved conversations.

MCP server

Included with your purchase. Sign in to read, or open it in your download.

The MCP endpoint for coding agents and how it is authorised.

Live permission updates

Included with your purchase. Sign in to read, or open it in your download.

The live connection the dashboard listens on for permission changes, its event and how it is authorised.

Demo mode routes

Included with your purchase. Sign in to read, or open it in your download.

The routes that exist only on a public demo build.

Stuck on a step?

Find a fix before you start over.

Troubleshooting

Cookie Preferences

We use cookies to enhance your browsing experience, analyze site traffic, and personalize content. By clicking "Accept All", you consent to our use of cookies for analytics and personalized advertising.