# Organization tools

[All tool areas](/docs/tools.md). Each tool acts within your access.

## Organization

### close_organization

Close the organization for good (the end of Lokl's Terms): online booking, staff changes, agents, in-app AI, and every email stop at once; members can still sign in to read and export its data (reports, lists, export_customer_data) for 90 days, and then it is deleted. Refused (`conflict`, saying what to do) while anything is still owed or due: an order waiting for payment, a booking still to come, a balance due, money owed back, a refund on its way or failed, a payment still processing, a gift certificate not yet delivered, an open quote, an email to a guest still being sent, or a Lokl plan that still renews (cancel it in the billing portal first). Guests' gift certificate and credit balances don't stop it: they stay the operator's to honour, and the preview says how much is outstanding. Owner only (organization:close). Can be undone for 15 minutes; after that, contact Lokl to reopen it before its data is deleted. Returns a preview to confirm.

Changes · Members of an organization · Needs organization:close

#### Input

- `reason` — string; optional. Why it's closing, kept in the activity log maxLength: 500

#### Output

- `organization` — string; required. The organization (org_…)
- `closedAt` — string; required.  format: "date-time"
- `purgeAfter` — string; required. When its data is deleted: until then members can read and export it format: "date-time"

### create_organization

Create a new organization with you as its owner, and the standard and exempt tax classes. Returns a preview to confirm; nothing is created until the changeset is applied. The slug is derived from the name unless you give one. Set undoable to false to give up the 15-minute undo, so the trial's AI credits arrive at once (the dashboard's sign-up does). The trial's AI credits come with a person's first organization only: every later one gets the 30-day trial without them. A person can create 3 organizations in any 24 hours (`conflict` after that).

Changes · Any signed-in person

#### Input

- `name` — string; required.  minLength: 1; maxLength: 100
- `slug` — string; optional.  minLength: 3; maxLength: 48; pattern: "^\[a-z0-9\]+(-\[a-z0-9\]+)\*$"
- `undoable` — boolean; optional. 
- `source` — object or null; optional. Where the sign-up came from, for Lokl's own analytics (the dashboard's sign-up sends its link's campaign parameters): { utmSource, utmMedium, utmCampaign, utmContent, utmTerm, referringDomain (a host name only), landingPath (starts with /) }, each up to 200 characters. Anything else is dropped; it is never shown back
  - `source.utmSource` — any value; optional. utm_source: who sent the visitor
  - `source.utmMedium` — any value; optional. utm_medium
  - `source.utmCampaign` — any value; optional. utm_campaign
  - `source.utmContent` — any value; optional. utm_content
  - `source.utmTerm` — any value; optional. utm_term
  - `source.referringDomain` — any value; optional. The referring site's host name only
  - `source.landingPath` — any value; optional. The first page's path, starting with /

#### Output

- `id` — string; required. 
- `name` — string; required. 
- `slug` — string; required. 

### export_organization

Export all of the organization's data as CSV files in one ZIP: customers, orders with their lines, bookings, payments, refunds, products, sessions, gift certificates, credits, invoices, quotes, staff notes, marketing consent and tips, money in each row's currency and times at each location's time zone. It's built in the background; you get an email with a download link that works for 7 days, and get_organization_export says when it's ready and gives the link. Asking while one is being built returns that one. Works while the organization is closed (its data can be exported until it's deleted). Owner only (organization:export). Returns a preview to confirm.

Changes · Members of an organization · Needs organization:export

No input.

#### Output

- `status` — string; required.  Value: "running"
- `running` — object; required. 
  - `running.id` — string; required. The export (oex_…)
  - `running.requestedAt` — string; required.  format: "date-time"
- `alreadyRunning` — boolean; required. True when an export was already being built and this is that one

### get_organization

Get the organization you're signed in to: its id, name, and slug. Use it to confirm which organization your other calls act in.

Reads · Members of an organization · Needs organization:read

No input.

#### Output

- `id` — string; required. 
- `name` — string; required. 
- `slug` — string; required. 
- `closedAt` — string or null; optional. When it was closed (close_organization): nothing can be changed, and its data can be read and exported until purgeAfter. Null while open. Always present format: "date-time"
- `purgeAfter` — string or null; optional. When a closed organization's data is deleted (90 days after closedAt). Null while open. Always present format: "date-time"

### update_organization

Rename the organization. Its slug and booking links don't change. Use get_organization to read its current name. Returns a preview to confirm; can be undone for 15 minutes unless the name changes again.

Changes · Members of an organization · Needs settings:write

#### Input

- `name` — string; required.  maxLength: 120

#### Output

- `organization` — object; required. 
  - `organization.id` — string; required. 
  - `organization.name` — string; required. 
  - `organization.slug` — string; required. 
