Skip to content

Run Biocompile analyses and approve spending through the API

Last updated

On this page

The Biocompile API starts the same analyses you start in the app, called Executables, and follows each one as a Run. A token plans an analysis to check its input and quote its cost, starts it, and downloads the results when the Run finishes. Starting needs runs:execute, and reading needs runs:read.

An analysis that costs credits needs a spending approval before it runs. In the app you give it with a click. Through the API, a token that also holds spending:approve can give it.

Paths start with /api/v1/organizations/{organization_id}.

Find an analysis

GET .../executables/catalog lists the analyses your organization can run, with their inputs. GET .../executables lists them with filters such as kind and search, and GET .../executables/{executable_id} reads one with its input schema.

Plan and start an analysis

A plan checks the input and quotes the cost without running or spending anything:

curl -s --request POST "https://app.biocompile.com/api/v1/organizations/$ORG_ID/executables/$EXECUTABLE_ID/invocation-plans" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{"input": {"samples": "/projects/kinase-screen/samples.csv"}}'

The plan’s approval says whether the run needs an approval, with a summary and a cost_estimate. A free analysis starts at once with POST .../executable-invocation-plans/{plan_id}/invoke. POST .../executables/{executable_id}/invoke plans and starts in one call.

When a plan expires or its quote changes, POST .../executable-invocation-plans/{plan_id}/refresh quotes it again.

Note: Send an idempotency_key in the body of every invocation and reuse it on a retry. A retried call then never starts the work twice.

If the input names files (by identifier, fil_…), the token also needs files:read, because the files are read with your permissions.

Choose a sandbox for an analysis

Some analyses run in one of your sandboxes. GET .../sandboxes/runnable lists the sandboxes you can run in, and you pass a slug as sandbox_slug in the context of the invocation.

Each sandbox has a status and a stack_status:

FieldValuesMeaning
statusready, starting, stopping, stopped, sleepingIts live state, as Compute shows it. Running in a sleeping sandbox restores its disk, which counts against your sandbox limit.
stack_statuscurrent, supported, deprecated, retiredThe lifetime of its software stack. Prefer current, because a run on a deprecated or retired stack may fail.

Approve spending without the app

A plan that costs credits waits for a spending approval. With runs:execute and spending:approve, a token approves the plan’s current quote and then starts it:

curl -s --request POST "https://app.biocompile.com/api/v1/organizations/$ORG_ID/executable-invocation-plans/$PLAN_ID/spending-approval" \
  -H "Authorization: Bearer $ACCESS_TOKEN" -H "Content-Type: application/json" \
  -d '{"binding": "'"$SPENDING_BINDING"'", "confirmed": true}'

The binding is the plan’s approval.spending_binding, or approval.binding when there is none. "confirmed": false declines instead. The approval covers that exact quote only, so a quote that changes needs a new approval.

When the assistant asked for network access for a Run, the plan’s network_request says what the Run would reach. Approving it is your decision to allow that, so add "network_acknowledged": true to the approval. Without it the approval is refused and the Run does not start; to run offline instead, decline and plan the Run again without network access. The approval record names the token that gave it.

Some analyses also ask for an exact-call approval. With spending:approve, send "direct_user_intent": true and the plan’s approval_binding when you invoke the plan.

Every limit of the app still applies after the approval:

  • The plan must be your own.
  • Your organization’s paid-tool setting, credit balance and usage limits decide.
  • Your organization’s network policy decides whether a Run may reach the internet.

Without spending:approve, these calls answer 403 with the code insufficient_scope, and a person approves the plan in the app.

Follow a Run and fetch its results

A Run moves through queued and running to succeeded, failed, cancelled or timed_out. These operations follow it:

OperationWhat it does
GET .../runsLists Runs, filtered by status, project_slug or executable_slug
GET .../runs/{run_slug}Reads one Run with its status, outputs and billing
GET .../runs/{run_slug}/logsReads its log, a page at a time with after
GET .../runs/{run_slug}/artifacts/{artifact_id}/downloadDownloads one retained artifact, including an output a Run placed in its sandbox
POST .../runs/{run_slug}/cancelCancels it, with runs:execute

Downloading never starts a sandbox. An output in a sandbox needs access to that sandbox’s files, and one larger than 16 MB needs the sandbox running first.

Poll a Run no more than every few seconds, or subscribe to the run.completed and run.failed webhook events instead.

Common questions

Can a script spend credits without anyone opening Biocompile?

Yes, if its token holds runs:execute and spending:approve. Your organization’s spending limits and paid-tool settings still apply to every approval.

Does planning an analysis cost anything?

No. A plan checks the input and quotes the cost without running or spending anything.

How do I avoid starting the same analysis twice on a retry?

Send the same idempotency_key in the body of every attempt. A retried invocation with that key does not start the work again.

Controller: Biocompile, Inc.

Your first project starts here.

Free to start, with credits included.

We use this address to prefill your signup. A founder may email you once to help you get started. No newsletter. Privacy Policy

Already have an account? Sign in