Schnellstart
This takes about ten minutes. You need to be an owner or admin of your Ivy organisation, and the organisation needs code runs (they need gVisor sandboxes; see Self-hosting if you run Ivy yourself).
1. Create a service identity
A service identity is how an integration acts in Ivy without a person behind it. In the Ivy app, open Service identities under your organisation in the navigation, choose Create service identity and name it after the integration (for example “Nightly report”). If you signed in more than 10 minutes ago, Ivy first asks you to Confirm it’s you with your password, a passkey or your sign-in provider.
On the service identity’s page, the Budget section sets its Share of the allowance and a Spending limit, so it can’t use more of your organisation’s AI credits than you intend.
2. Give it a space
A service identity only sees the spaces you add it to, with a space role, just like a person. In Space access, choose Add to space, pick one space and the role Editor: uploading files and starting code runs need the editor or admin role.
3. Create an API key
In API keys, choose Create API key, give the key a name and set its scopes:
- Spaces: Read (
workspaces:read) to list its spaces; - Files: Read and write (
files:write) to upload files (writeincludesread); - Code runs: Read and write (
code_runs:write) to start code runs and read their output.
Ivy shows the key once. It looks like ivy_sk_ followed by a 12-character key ID, an underscore and 49 more characters. Choose Copy, store it in your secrets vault and confirm with I’ve stored it. Then export it with your organisation’s ID (the part after /organisations/ in the app’s address) for the commands below:
export IVY_API_URL="https://app.ivy.work/api"
export IVY_API_KEY="ivy_sk_…" # from your secrets vault
export IVY_ORGANISATION_ID="…" # from the app’s address: /organisations/<id>/…
4. Make your first request
Ask Ivy which key you’re using:
curl "$IVY_API_URL/v1/api-key" -H "Authorization: Bearer $IVY_API_KEY"
A 200 response names the key, its scopes, its expiry, its service identity and the organisation. A 401 with the code unauthenticated means the key is missing, mistyped, expired or revoked; see Errors.
Then list the spaces the service identity belongs to, and note the space’s id:
curl "$IVY_API_URL/v1/organisations/$IVY_ORGANISATION_ID/spaces" \
-H "Authorization: Bearer $IVY_API_KEY"
export IVY_SPACE_ID="…"
5. Upload a file
Create a small Python file and upload it to the space’s top folder. The body is the file’s raw content and name is its file name:
printf 'print("Hello from Ivy")\n' > hello.py
curl -X POST "$IVY_API_URL/v1/organisations/$IVY_ORGANISATION_ID/spaces/$IVY_SPACE_ID/files?name=hello.py" \
-H "Authorization: Bearer $IVY_API_KEY" \
--data-binary @hello.py
The 201 response is the new file. Note its id:
export IVY_FILE_ID="…"
Every upload is scanned for malware before anyone can use it, so the file starts with "scan_status": "scanning". Read the file again until it says clean, usually after a few seconds:
curl "$IVY_API_URL/v1/organisations/$IVY_ORGANISATION_ID/spaces/$IVY_SPACE_ID/files/$IVY_FILE_ID" \
-H "Authorization: Bearer $IVY_API_KEY"
6. Start a code run
Start a run of the file. client_run_id is your own ID for this run: if you send the same request again, for example after a timeout, you get the same run instead of a second one (see Idempotency).
curl -X POST "$IVY_API_URL/v1/organisations/$IVY_ORGANISATION_ID/spaces/$IVY_SPACE_ID/files/$IVY_FILE_ID/runs" \
-H "Authorization: Bearer $IVY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"client_run_id": "quickstart-1"}'
The 202 response has the run_id and the run’s timeout_seconds:
export IVY_RUN_ID="…"
7. Follow the run
The run’s output arrives as server-sent events. -N turns off curl’s buffering, so you see each event as it comes:
curl -N "$IVY_API_URL/v1/organisations/$IVY_ORGANISATION_ID/spaces/$IVY_SPACE_ID/runs/$IVY_RUN_ID/events" \
-H "Authorization: Bearer $IVY_API_KEY" \
-H "Accept: text/event-stream"
id: 1
event: run_status
data: {"status":"starting"}
id: 2
event: run_status
data: {"status":"running"}
id: 3
event: stdout
data: {"data":"Hello from Ivy\n"}
…
id: 7
event: done
data: {"status":"succeeded","exit_code":0,"outputs":[],"cpu_millis":41,"credits":0.01}
The stream ends after done or error. If the connection drops, the run carries on; reconnect with the id of the last event you received in a Last-Event-ID header to get the rest.
Next steps
- Read Authentication before you put a key into production: rotation, expiry and what a key can’t do.
- Stream an assistant reply with the JavaScript SDK; that needs a key with
conversations:write. - Browse the API reference.