> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tplus.cx/llms.txt
> Use this file to discover all available pages before exploring further.

# Signing

> Canonical Ed25519 payloads for orders, cancels, replaces, and user actions.

Every signed mutation has two checks:

1. Session auth: sign the OMS nonce `value` as raw UTF-8 bytes, then exchange it at `POST /auth`.
2. Action auth: sign the action-specific signable object as compact JSON bytes.

Do not hash the payload. Serialize the signable object to JSON, remove ASCII space, CR, and LF bytes from the serialized string, then Ed25519-sign the resulting UTF-8 bytes. Avoid those bytes inside signed string values. The SDK is the reference implementation; the raw form below is what it produces.

Verified signable objects:

| Action                                                                              | Request field that is signed                                                                |
| ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `POST /orders/create`                                                               | `order`                                                                                     |
| `PATCH /orders/replace`                                                             | `request`                                                                                   |
| `DELETE /orders/cancel`                                                             | `cancel`                                                                                    |
| Withdrawal, withdrawal cancel, transfer, close-position, multisig, batch settlement | `inner`                                                                                     |
| Single settlement                                                                   | `inner.to_bytes()`; a compact JSON signing view of `inner`, with `vault` omitted when unset |

## Raw signing

```python theme={null}
import json
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey

signable = {"order_id": "docs-gtc-1", "asset_id": "200", "...": "..."}
payload = json.dumps(signable, separators=(",", ":"))
payload = payload.replace(" ", "").replace("\r", "").replace("\n", "").encode("utf-8")
signature = private_key.sign(payload)
```

For `curl`, put the signature bytes into the request body as a JSON array of integers. The API references for the request wrappers are live at [OMS](https://oms.tplus.cx/api-reference).

## tpluspy

```python theme={null}
from tplus.model.asset_identifier import AssetIdentifier
from tplus.model.limit_order import GTC
from tplus.model.order import TradeTarget
from tplus.utils.limit_order import create_limit_order_ob_request_payload
from tplus.utils.user import User

user = User()  # fresh local Ed25519 keypair
signed = create_limit_order_ob_request_payload(
    asset_identifier=AssetIdentifier(200),
    price=250000,
    quantity=125000000,
    side="Buy",
    signer=user,
    book_price_decimals=2,
    book_quantity_decimals=8,
    target=TradeTarget(account=1, is_spot=False),
    time_in_force=GTC(post_only=False),
    order_id="docs-gtc-1",
    max_trading_fees_rate=50000,
)
print(signed.model_dump(mode="json"))
```

## Test vectors

Generated with a fresh throwaway Ed25519 key through `tpluspy` utilities. Public key:

```text theme={null}
6c54e822558e30315466058c4baf0e2ddca528961fcc3e858b66cf9635f000df
```

### Create order

Signable object: `order`.

```json theme={null}
{"signer":"6c54e822558e30315466058c4baf0e2ddca528961fcc3e858b66cf9635f000df","order_id":"docs-gtc-1","base_asset":"200","book_price_decimals":2,"book_quantity_decimals":8,"details":{"Limit":{"limit_price":250000,"quantity":125000000,"time_in_force":{"GTC":{"post_only":false}}}},"side":"Buy","trigger":null,"creation_timestamp_ns":1760000000000000000,"target":{"account":1,"is_spot":false},"reduce_only":false,"max_trading_fees_rate":50000,"protocol_version":1}
```

Payload bytes, hex:

```text theme={null}
7b227369676e6572223a2236633534653832323535386533303331353436363035386334626166306532646463613532383936316663633365383538623636636639363335663030306466222c226f726465725f6964223a22646f63732d6774632d31222c22626173655f6173736574223a22323030222c22626f6f6b5f70726963655f646563696d616c73223a322c22626f6f6b5f7175616e746974795f646563696d616c73223a382c2264657461696c73223a7b224c696d6974223a7b226c696d69745f7072696365223a3235303030302c227175616e74697479223a3132353030303030302c2274696d655f696e5f666f726365223a7b22475443223a7b22706f73745f6f6e6c79223a66616c73657d7d7d7d2c2273696465223a22427579222c2274726967676572223a6e756c6c2c226372656174696f6e5f74696d657374616d705f6e73223a313736303030303030303030303030303030302c22746172676574223a7b226163636f756e74223a312c2269735f73706f74223a66616c73657d2c227265647563655f6f6e6c79223a66616c73652c226d61785f74726164696e675f666565735f72617465223a35303030302c2270726f746f636f6c5f76657273696f6e223a317d
```

Signature bytes, hex:

```text theme={null}
a13816fafb9185f6bab22ec2e54f13fa789cf72bbf6abaca13624f1c2abbc57bbee0c1278d6048f658fac0e4d8b2c0e57153fe48d61aef225c07bec55e077802
```

Request body:

```json theme={null}
{
  "order": {
    "signer": "6c54e822558e30315466058c4baf0e2ddca528961fcc3e858b66cf9635f000df",
    "order_id": "docs-gtc-1",
    "base_asset": "200",
    "book_price_decimals": 2,
    "book_quantity_decimals": 8,
    "details": {"Limit": {"limit_price": 250000, "quantity": 125000000, "time_in_force": {"GTC": {"post_only": false}}}},
    "side": "Buy",
    "trigger": null,
    "creation_timestamp_ns": 1760000000000000000,
    "target": {"account": 1, "is_spot": false},
    "reduce_only": false,
    "max_trading_fees_rate": 50000,
    "protocol_version": 1
  },
  "signature": [161,56,22,250,251,145,133,246,186,178,46,194,229,79,19,250,120,156,247,43,191,106,186,202,19,98,79,28,42,187,197,123,190,224,193,39,141,96,72,246,88,250,192,228,216,178,192,229,113,83,254,72,214,26,239,34,92,7,190,197,94,7,120,2],
  "post_sign_timestamp": 1760000000000000100
}
```

### Replace order

Signable object: `request`.

```json theme={null}
{"order_id":"docs-gtc-1","timestamp_ns":1760000000000001000,"new_price_limit":251000,"new_quantity":100000000,"new_trigger":null,"book_quantity_decimals":8,"book_price_decimals":2,"protocol_version":1}
```

Payload bytes, hex:

```text theme={null}
7b226f726465725f6964223a22646f63732d6774632d31222c2274696d657374616d705f6e73223a313736303030303030303030303030313030302c226e65775f70726963655f6c696d6974223a3235313030302c226e65775f7175616e74697479223a3130303030303030302c226e65775f74726967676572223a6e756c6c2c22626f6f6b5f7175616e746974795f646563696d616c73223a382c22626f6f6b5f70726963655f646563696d616c73223a322c2270726f746f636f6c5f76657273696f6e223a317d
```

Signature bytes, hex:

```text theme={null}
bfec4df42b1c0230de81e36c1370feacc6d7383a6a736689f94974d02b28f53fd5e83f092eb934302ba7efeedd21aa321ec3a4550ffa420714010ad4422b7505
```

Request body:

```json theme={null}
{
  "request": {
    "order_id": "docs-gtc-1",
    "timestamp_ns": 1760000000000001000,
    "new_price_limit": 251000,
    "new_quantity": 100000000,
    "new_trigger": null,
    "book_quantity_decimals": 8,
    "book_price_decimals": 2,
    "protocol_version": 1
  },
  "signer": "6c54e822558e30315466058c4baf0e2ddca528961fcc3e858b66cf9635f000df",
  "asset_id": "200",
  "signature": [191,236,77,244,43,28,2,48,222,129,227,108,19,112,254,172,198,215,56,58,106,115,102,137,249,73,116,208,43,40,245,63,213,232,63,9,46,185,52,48,43,167,239,238,221,33,170,50,30,195,164,85,15,250,66,7,20,1,10,212,66,43,117,5],
  "post_sign_timestamp": 1760000000000000200
}
```

### Cancel order

Signable object: `cancel`.

```json theme={null}
{"order_id":"docs-gtc-1","asset_id":"200","signer":"6c54e822558e30315466058c4baf0e2ddca528961fcc3e858b66cf9635f000df","protocol_version":1}
```

Payload bytes, hex:

```text theme={null}
7b226f726465725f6964223a22646f63732d6774632d31222c2261737365745f6964223a22323030222c227369676e6572223a2236633534653832323535386533303331353436363035386334626166306532646463613532383936316663633365383538623636636639363335663030306466222c2270726f746f636f6c5f76657273696f6e223a317d
```

Signature bytes, hex:

```text theme={null}
f62bbb886b08f16080daa4a2b37ddfe1ee151950e59dce56dc0a0b7511472a37930a10d4ea510d042ef43b31be05fabdca8a57a6cf699c8661811af7c117b000
```

Request body:

```json theme={null}
{
  "cancel": {
    "order_id": "docs-gtc-1",
    "asset_id": "200",
    "signer": "6c54e822558e30315466058c4baf0e2ddca528961fcc3e858b66cf9635f000df",
    "protocol_version": 1
  },
  "signature": [246,43,187,136,107,8,241,96,128,218,164,162,179,125,223,225,238,21,25,80,229,157,206,86,220,10,11,117,17,71,42,55,147,10,16,212,234,81,13,4,46,244,59,49,190,5,250,189,202,138,87,166,207,105,156,134,97,129,26,247,193,23,176,0],
  "post_sign_timestamp": 1760000000000000300
}
```
