> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.immix.xyz/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.immix.xyz/_mcp/server.

# Create an algo instance

POST /algos/instances
Content-Type: application/json

Creates an instance of a loaded algo version with its config document in the same request (`algos:manage`). The document is validated before anything exists — grammar, the version's schema, its account and instrument references; a refusal is 422, naming the field. Answers 201 — [the guide](https://docs.immix.xyz/guides/rest-api-guide#algos).

Reference: https://docs.immix.xyz/api-reference/rest-api/algos/create-instance

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Headers

- `Idempotency-Key` (string, required) — Required on every write: a URL-safe string of 1 to 64 characters from `[A-Za-z0-9._~-]` (a UUID fits), scoped to you. It names one operation on one record, ever: a retry replays the stored outcome (`Idempotent-Replay: true`) or attaches to the live one, and reuse on another record refuses 409 `IDEMPOTENCY_KEY_REUSED`. Missing or malformed, 400.

### Body (application/json)

This endpoint expects an object.

- `algoVersionId` (integer, required) — The loaded algo version to instantiate — a catalog row.
- `pool` (string, required) — The engine pool the instance runs on, by name — the algo-engine- prefix and a tier, at most 64 printable ASCII characters without a space; fixed at creation.
- `displayName` (string, required) — The instance's display name, at most 64 bytes of UTF-8.
- `remark` (string, required) — Why — required on every change, at most 256 bytes of UTF-8.
- `document` (string, required) — The initial config document: JSON with comments, one object the version's params schema types whole, its accounts and instruments among its values as typed references — each an id, or through the trading gateway a name (an account's display name, an instrument's platform symbol such as OKX@BTC/USDT), which the gateway replaces with the id it names before the command is sent, keeping the name beside it as a comment where it fits; at most 6144 bytes of UTF-8 as written and as sent, and its distinct references at most 1280 bytes, 4 an account and 8 an instrument.
- `commandKey` (string, optional) — The command's idempotency key, 1 to 64 characters of letters, digits, dot, underscore, tilde and hyphen; a replay restates the earlier answer.

## Response

### 201

The instance exists, with its first document staged: the created row, `CREATED` until the engine applies the document — with the position of the second of the two changes the create landed, the row's `ETag` (`configSeq`, 1) and, on a replayed key, `Idempotent-Replay`.

- `algoVersionId` (integer, required) — The catalog version the instance runs (`GET /algos/versions`).
- `appliedConfigSeq` (integer, required) — The document in force; 0 while none has been applied.
- `configSeq` (integer, required) — The latest staged document's sequence number — the `ETag`, and what `If-Match` takes on a config write.
- `createdAtNs` (string, required) — When it was created — epoch nanoseconds as a decimal string.
- `displayName` (string, required) — The instance's display name, as created.
- `globalSequence` (string, required) — The position as a decimal string — the last change this member had applied, orders, balance readings and algo instances included.
- `instanceId` (integer, required) — The instance's id — the value its orders carry as `algoInstanceId`.
- `lastCause` (enum, required) — Why it last moved: a command, the organisation's halt, its first document applied, the engine's fault trip, or the engine's divergence check. The value set is append-only: read an unknown name as `UNKNOWN`.
  - Allowed values: `UNKNOWN`, `COMMAND`, `HALT`, `CONFIG_APPLIED`, `ENGINE_FAULT`, `DIVERGED`
- `lastCommandKind` (enum, required) — The command behind the last move — a desk's, or the engine's report that moved it. The value set is append-only: read an unknown name as `UNKNOWN`.
  - Allowed values: `UNKNOWN`, `CREATE_ALGO_INSTANCE`, `SUBMIT_ALGO_CONFIG`, `START_ALGO_INSTANCE`, `STOP_ALGO_INSTANCE`, `DELETE_ALGO_INSTANCE`, `HALT_ALGOS`, `REPORT_ALGO_VERSIONS`, `REPORT_ALGO_CONFIG_OUTCOME`, `REPORT_ALGO_INSTANCE_FAULT`
- `lastUpdatedAtNs` (string, required) — When it last moved — epoch nanoseconds as a decimal string.
- `orgId` (integer, required) — The organisation that owns the instance.
- `pool` (string, required) — The engine pool the instance runs on, fixed at creation.
- `status` (enum, required) — Where the instance stands: `CREATED` until its first document is applied, `STOPPED` or `STARTED` under the desk, `ERROR` after the engine's fault trip (left only by a stop), `DELETED` terminal. `PENDING_APPROVAL` and `DISABLED` are reserved and never served today. The value set is append-only: read an unknown name as `UNKNOWN`.
  - Allowed values: `UNKNOWN`, `CREATED`, `STOPPED`, `STARTED`, `ERROR`, `DELETED`, `PENDING_APPROVAL`, `DISABLED`
- `transitionSeq` (integer, required) — The instance's transition number: 1 at creation, one more on every move.
- `createdByUserId` (integer, optional, nullable) — The user who created the instance.
- `lastUpdatedByUserId` (integer, optional, nullable) — The user whose command last moved the instance; null when the engine or the platform's own rule did — `lastCause` says which.
- `pendingByUserId` (integer, optional, nullable) — Reserved; always null.
- `unscaled` (boolean, optional, deprecated) — Never present since 0.3.3: every money value on this API states its own scale on the wire — a policy amount or cap since 0.3.3, an order's and an execution's since 0.3.2, a balance's since 0.3.1 — so a row is never served raw, whether or not this member holds the asset or instrument it references. Kept, deprecated, so a client generated from 0.3.2 still compiles; it goes at the next major.

## Errors

### 400 Create Instance Algos Request Bad Request Error

Refused at the door — nothing reached the platform and the key was not journaled: a missing or malformed `Idempotency-Key` or `If-Match`, malformed JSON, a body `userId`, a body restating the path or `If-Match` differently, a money string off its `pattern` (an exponent, a plus sign, a bare point, surrounding whitespace) or past its `maxLength`, or one no value here can state (over 18 fractional digits, or past a 64-bit integer at its own scale), or any other value outside the schema.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 401 Create Instance Algos Request Unauthorized Error

No bearer token, or one that does not verify.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 403 Create Instance Algos Request Forbidden Error

Authenticated, but not admitted. `FORBIDDEN_PRINCIPAL`: a token with no `org_id`, a non-ASCII `org_id` or `sub`, a disabled user, or a local binding with no user. `AWAITING_ADMISSION`: your user is not yet admitted — every route but `GET /me` answers this until an administrator admits you. `ORG_NOT_ACTIVE`: your organisation is suspended, pending activation, retired or unregistered. The record owners' 403s (`CAPABILITY_DENIED`, `SELF_APPROVAL`, `NOT_PROPOSER`, …) are refusals on the platform's stream: they carry the position header, and a retried key replays them with `Idempotent-Replay`.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 404 Create Instance Algos Request Not Found Error

The door's `NOT_FOUND`: no such instance in your organisation — another organisation's is indistinguishable from an absent one; the position header says as of when, and nothing was journaled. Or the platform's own refusal, a fact on its stream that a retried key replays: `UNKNOWN_INSTANCE` (the instance vanished in the catch-up window) and, on a create, `UNKNOWN_ALGO_VERSION` (no catalog row under the version the body named).

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 409 Create Instance Algos Request Conflict Error

The record owner's refusal, by class: 409 for a state or uniqueness refusal, 422 for a field or reference refusal — a fact on the platform's stream, so it carries the position header and a retried key replays it. The same statuses carry door refusals, never journaled — a retry takes fresh: 409 `IDEMPOTENCY_KEY_REUSED`; 422 for a name nothing here holds, `INSTRUMENT_NOT_LIVE` or `ACCOUNT_NOT_ACTIVE` on `POST /orders` and `REFERENCE_UNKNOWN_INSTRUMENT` or `REFERENCE_UNKNOWN_ACCOUNT` in an algo document — each the owner's code for an id it rejects; a key the member holds answers as its retry.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 413 Create Instance Algos Request Content Too Large Error

`DOCUMENT_TOO_LARGE`: the config document is past the platform's bound (6144 bytes of UTF-8) — refused at the door on the text's bytes — as written, or once its names are replaced by their ids — nothing sent, the key retries fresh; the platform answers the same code to the same bytes. Or `TOO_LARGE`, the platform's refusal of the whole command's size. Neither is journaled.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 422 Create Instance Algos Request Unprocessable Entity Error

The record owner's refusal, by class: 409 for a state or uniqueness refusal, 422 for a field or reference refusal — a fact on the platform's stream, so it carries the position header and a retried key replays it. The same statuses carry door refusals, never journaled — a retry takes fresh: 409 `IDEMPOTENCY_KEY_REUSED`; 422 for a name nothing here holds, `INSTRUMENT_NOT_LIVE` or `ACCOUNT_NOT_ACTIVE` on `POST /orders` and `REFERENCE_UNKNOWN_INSTRUMENT` or `REFERENCE_UNKNOWN_ACCOUNT` in an algo document — each the owner's code for an id it rejects; a key the member holds answers as its retry.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 429 Create Instance Algos Request Too Many Requests Error

Shed at once: `INBOX_FULL` or `IN_FLIGHT_FULL` (this member's bounds; nothing queued, the key not journaled), the intake's `RATE_LIMITED`, or the orders owner's `RATE_CEILING` (the organisation's per-minute ceiling — a refusal on the stream, replayed like any). `Retry-After` says when.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 500 Create Instance Algos Request Internal Server Error

The gateway failed to serve (`INTERRUPTED`, `INTERNAL_ERROR`, `PROJECTION_MISS`); the operation record, if one exists, is still readable.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

### 503 Create Instance Algos Request Service Unavailable Error

This member cannot serve the algos surface now: `NOT_PRIMED` — it is still catching up; retry shortly — or `ALGOS_UNAVAILABLE` — it is deployed without the surface, because the algos owner is not released into its environment yet, so no instance is readable or commandable here and a retry changes nothing; every other route is unaffected. On a write also `NOT_SERVING`, `OWNER_ABSENT`, or the platform's own outcome for a command lost in transit — nothing journaled; retry against a serving member.

- `error` (ErrorError, required)
- `currentVersion` (string, optional) — On 412 `VERSION_CONFLICT`, or `CONFIG_SEQ_CONFLICT` on an algo instance's config write: the row's current version (the `ETag` carries the same token) — re-read, reapply, retry.

## Types

### ErrorError

- `code` (string, required) — The code to branch on — stable and append-only: treat one you do not know by its HTTP status. The gateway's own: - 400: `MALFORMED_REQUEST`, `MISSING_IDEMPOTENCY_KEY`, `INVALID_IDEMPOTENCY_KEY`, `INVALID_IF_MATCH` - 401: `UNAUTHENTICATED` - 403: `FORBIDDEN_PRINCIPAL`, `AWAITING_ADMISSION`, `ORG_NOT_ACTIVE`, `CAPABILITY_DENIED` (the credential intake) - 404: `NOT_FOUND`, `UNKNOWN_OPERATION` - 409: `IDEMPOTENCY_KEY_REUSED`, `INTAKE_KEY_REUSED` - 413: `TOO_LARGE`, `PAYLOAD_TOO_LARGE`, `DOCUMENT_TOO_LARGE` - 422: a name nothing here holds: `INSTRUMENT_NOT_LIVE`, `ACCOUNT_NOT_ACTIVE` (`POST /orders`), `REFERENCE_UNKNOWN_INSTRUMENT`, `REFERENCE_UNKNOWN_ACCOUNT` (an algo document); `VENUE_UNSUPPORTED`; `SCALE_UNKNOWN` (retired at `0.3.4`) - 429: `INBOX_FULL`, `IN_FLIGHT_FULL`, `RATE_LIMITED` - 500: `INTERRUPTED`, `INTERNAL_ERROR`, `PROJECTION_MISS` - 503: `NOT_PRIMED`, `NOT_SERVING`, `OWNER_ABSENT`, `INTAKE_UNAVAILABLE`, `BALANCES_UNAVAILABLE`, `ALGOS_UNAVAILABLE`, `LOST`, `REJECTED_NOT_REGISTERED`, `REJECTED_NOT_ACTIVE` The record owners' refusals ride verbatim — `OrgRegisterRejected.reason`, `OrderRejected.reason` and `AlgoRejected.reason` list them; the guide maps each to its status.
- `message` (string, optional) — Free text for humans; may change without notice — never parse it.

## Examples

**Request**

```json
{
  "algoVersionId": 1,
  "pool": "pool",
  "displayName": "displayName",
  "remark": "remark",
  "document": "document"
}
```

**Response**

```json
{
  "algoVersionId": 1,
  "appliedConfigSeq": 1,
  "configSeq": 1,
  "createdAtNs": "createdAtNs",
  "displayName": "displayName",
  "globalSequence": "globalSequence",
  "instanceId": 1,
  "lastCause": "UNKNOWN",
  "lastCommandKind": "UNKNOWN",
  "lastUpdatedAtNs": "lastUpdatedAtNs",
  "orgId": 1,
  "pool": "pool",
  "status": "UNKNOWN",
  "transitionSeq": 1,
  "createdByUserId": 1,
  "lastUpdatedByUserId": 1,
  "pendingByUserId": 1
}
```

**SDK Code**

```python
import requests

url = "https://api.example.com/algos/instances"

payload = {
    "algoVersionId": 1,
    "pool": "pool",
    "displayName": "displayName",
    "remark": "remark",
    "document": "document"
}
headers = {
    "Idempotency-Key": "Idempotency-Key",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.example.com/algos/instances';
const options = {
  method: 'POST',
  headers: {
    'Idempotency-Key': 'Idempotency-Key',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"algoVersionId":1,"pool":"pool","displayName":"displayName","remark":"remark","document":"document"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/algos/instances"

	payload := strings.NewReader("{\n  \"algoVersionId\": 1,\n  \"pool\": \"pool\",\n  \"displayName\": \"displayName\",\n  \"remark\": \"remark\",\n  \"document\": \"document\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Idempotency-Key", "Idempotency-Key")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.example.com/algos/instances")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = 'Idempotency-Key'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"algoVersionId\": 1,\n  \"pool\": \"pool\",\n  \"displayName\": \"displayName\",\n  \"remark\": \"remark\",\n  \"document\": \"document\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.example.com/algos/instances")
  .header("Idempotency-Key", "Idempotency-Key")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"algoVersionId\": 1,\n  \"pool\": \"pool\",\n  \"displayName\": \"displayName\",\n  \"remark\": \"remark\",\n  \"document\": \"document\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.example.com/algos/instances', [
  'body' => '{
  "algoVersionId": 1,
  "pool": "pool",
  "displayName": "displayName",
  "remark": "remark",
  "document": "document"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'Idempotency-Key' => 'Idempotency-Key',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.example.com/algos/instances");
var request = new RestRequest(Method.POST);
request.AddHeader("Idempotency-Key", "Idempotency-Key");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"algoVersionId\": 1,\n  \"pool\": \"pool\",\n  \"displayName\": \"displayName\",\n  \"remark\": \"remark\",\n  \"document\": \"document\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Idempotency-Key": "Idempotency-Key",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "algoVersionId": 1,
  "pool": "pool",
  "displayName": "displayName",
  "remark": "remark",
  "document": "document"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.example.com/algos/instances")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```