# Process cold vault operations with the API

Use this page for programmatic cold vault operations. For the conceptual model, see [Cold vaults](/pt-br/products/custody/v1.34/concepts/cold-vaults).

Cold vault workflows involve two systems:

- The online Ripple Custody (Vault) API, which requires JWT authentication.
- The cold bridge API, which runs on the cold vault server and provides local endpoints for upload, status, download, and payload inspection.


## API endpoints

| Operation | System | Endpoint |
|  --- | --- | --- |
| Export pending operations | Online API | [Export prepared operations](/pt-br/products/custody/v1.34/api/reference/openapi/vaults/paths/~1v1~1vaults~1{vaultid}~1operations~1prepared/get) |
| Import signed operations | Online API | [Import signed operations](/pt-br/products/custody/v1.34/api/reference/openapi/vaults/paths/~1v1~1vaults~1operations~1signed/post) |
| Get vault details | Online API | [Get vault details](/pt-br/products/custody/v1.34/api/reference/openapi/vaults/getvault) |
| Upload operations | Cold bridge | `POST {ColdBridgeURL}/v1/feed/upload` |
| Check signing status | Cold bridge | `GET {ColdBridgeURL}/v1/feed/status` |
| Download signed operations | Cold bridge | `GET {ColdBridgeURL}/v1/feed/download` |
| Decode payload | Cold bridge | `POST {ColdBridgeURL}/v1/feed/decode` |


## Complete the first-time vault handshake

When you register a new cold vault, it can start in a `Pending` state because the cold vault cannot automatically connect to the online deployment. Complete the handshake by downloading the vault payload from the cold bridge and importing it into Ripple Custody (Vault).

1. On the cold vault server, download the vault payload from the cold bridge:

```sh
curl -X GET "{ColdBridgeURL}/v1/feed/download?clean=false" \
  --output cold-vault-handshake.dat
```
The `clean` parameter is optional. `clean=true` clears the cold bridge cache after the download, and `clean=false` keeps the payload available so you can download it again if the import fails. The cold bridge UI always downloads with `clean=true`.
2. Transfer `cold-vault-handshake.dat` to the online environment using your approved transfer process.
3. Import the payload into Ripple Custody (Vault) with [Import signed operations](/pt-br/products/custody/v1.34/api/reference/openapi/vaults/paths/~1v1~1vaults~1operations~1signed/post):

```sh
curl -X POST "${CUSTODY_API_URL}/v1/vaults/operations/signed" \
  -H "Authorization: Bearer ${JWT_TOKEN}" \
  -F "files=@cold-vault-handshake.dat"
```
4. Verify that the vault status is `Completed`:

```sh
curl -X GET "${CUSTODY_API_URL}/v1/vaults/${VAULT_ID}" \
  -H "Authorization: Bearer ${JWT_TOKEN}"
```


After the vault status is `Completed`, you can use the vault for account creation, transactions, and manifests.

## Process accounts, transactions, or manifests

Accounts and manifests created for a cold vault remain `Pending`, and transaction orders remain `Prepared`, until the cold vault signs the exported operations. You can batch multiple unsigned operations into the same export.

### Step 1: Export pending operations

Call [Export prepared operations](/pt-br/products/custody/v1.34/api/reference/openapi/vaults/paths/~1v1~1vaults~1{vaultid}~1operations~1prepared/get):

```sh
curl -X GET "${CUSTODY_API_URL}/v1/vaults/${VAULT_ID}/operations/prepared" \
  -H "Authorization: Bearer ${JWT_TOKEN}" \
  --output cold-vault-operations.dat
```

Transfer `cold-vault-operations.dat` to the cold vault server using your approved transfer process.

### Step 2: Decode and verify the payload

The cold bridge doesn't require this step, but it's the only point where you can see what the cold vault signs. Decode and review every payload before you upload it.

To decode the exported file, call the cold bridge decode endpoint:

```sh
curl -X POST "{ColdBridgeURL}/v1/feed/decode" \
  -F "files=@cold-vault-operations.dat"
```

The endpoint returns a JSON array with one element for each uploaded file. Each element is an array of the operations in that file, in this order: accounts, transactions, manifests, and rewraps. When you decode a signed file returned by the cold vault, the first entry is the vault registration.

Each entry is the vault's protobuf message for that operation, converted to JSON field by field. The endpoint doesn't format values according to what they represent, and has no option to return decimal or hexadecimal values. To read the output:

- Field names are in snake_case, such as `seq_num`, not the camelCase names used in the protobuf definitions.
- A field that holds one of several options (a protobuf `oneof`) is nested twice: under the field name, then under the name of the option that is set. For example, a transaction destination appears under `data`, with one key that holds either an external address string or an internal account object.
- Enumerations, such as the ledger or signing algorithm, are numbers, not names.
- An unset field is `null`.


Read each value according to its protobuf type:

| Protobuf type | JSON form | How to read it |
|  --- | --- | --- |
| `Value` | `{"value": [1, 134, 160]}` | An unsigned big-endian integer stored as bytes. `null` and `{"value": []}` both mean zero. What the integer represents depends on the ledger and the field. See [Amounts](#amounts). |
| `Bytes`, and binary fields such as hashes, public keys, and signatures | Array of byte values, wrapped as `{"value": [...]}` for `Bytes` | Raw bytes. Convert to hexadecimal to compare with other tools. |
| `U32`, `U64`, and other integer fields | Number, wrapped as `{"value": 5}` for `U32` and `U64` | Use as is. |
| Floating-point fields | Decimal number | Use as is. |
| Text fields | String | Use as is. |


#### Amounts

Most amounts and fees are `Value` integers in the smallest unit of the asset. This applies to the transaction amount and fee fields, native XRP amounts (in drops), and Solana, Substrate, Cardano, and Tezos amounts.

The following amounts use a different encoding:

- **XRPL issued tokens:** the amount is a `Value`, but it's a fixed-point decimal with 81 decimal places, not an integer in the smallest unit. Divide it by 1081. For example, 1 USD is encoded as 1081.
- **XRPL Multi-Purpose Tokens (MPTs):** the amount is a `U64`, so it's a number, not a byte array.
- **Bitcoin fee settings:** the fee rate is a decimal number in satoshis per virtual byte. The change amount and dust limit are numbers in satoshis.
- **Other ledger-specific settings,** such as gas prices and budgets, fee limits, nonces, and chain IDs, are numbers.


For example, to convert values in Python:

```python
from decimal import Decimal

def to_int(v):
    return int.from_bytes(bytes(v["value"]), "big") if v else 0

to_int({"value": [1, 134, 160]})              # amount in smallest unit: 100000
Decimal(to_int(token_amount)).scaleb(-81)      # XRPL issued token amount
bytes([222, 173, 190, 239]).hex()              # binary data: 'deadbeef'
```

The output contains 64-bit integers at full precision. Python's `json` module reads them exactly, but JavaScript and older versions of `jq` round integers larger than 253. Take this into account if you process the file with other tools.

For transactions, verify the destination address, amount, network, and fees before allowing the cold vault to sign.

Verify before signing
Cold vault signing is a high-control operation. Decode and review the payload before signing, especially for transactions. After a signed transaction broadcasts to the blockchain network, Ripple Custody (Vault) cannot recall it.

### Step 3: Upload operations to the cold bridge

Upload the exported file to the cold bridge:

```sh
curl -X POST "{ColdBridgeURL}/v1/feed/upload" \
  -F "files=@cold-vault-operations.dat"
```

After upload, the vault processes the data from the cold bridge and signs the pending operations.

### Step 4: Check signing status

Call the cold bridge status endpoint:

```sh
curl -X GET "{ColdBridgeURL}/v1/feed/status"
```

The response includes counters for unsigned and signed operations:

```json
{
  "accountToSign": 0,
  "accountSigned": 0,
  "transactionToSign": 0,
  "transactionSigned": 0,
  "manifestToSign": 0,
  "manifestSigned": 0
}
```

When the `ToSign` counters are zero, the vault has signed all operations in the uploaded payload.

### Step 5: Download signed operations

Download the signed payload from the cold bridge:

```sh
curl -X GET "{ColdBridgeURL}/v1/feed/download?clean=false" \
  --output signed-cold-vault-operations.dat
```

Transfer `signed-cold-vault-operations.dat` back to the online environment.

### Step 6: Import signed operations

Import the signed payload into Ripple Custody (Vault) with [Import signed operations](/pt-br/products/custody/v1.34/api/reference/openapi/vaults/paths/~1v1~1vaults~1operations~1signed/post):

```sh
curl -X POST "${CUSTODY_API_URL}/v1/vaults/operations/signed" \
  -H "Authorization: Bearer ${JWT_TOKEN}" \
  -F "files=@signed-cold-vault-operations.dat"
```

After import, Ripple Custody (Vault) continues processing the account, transaction, or manifest.

## Related topics

- [Process cold vault operations in the UI](/pt-br/products/custody/v1.34/ui/environment/vault/cold)
- [Cold vaults](/pt-br/products/custody/v1.34/concepts/cold-vaults)
- [Deploy a cold bridge](/pt-br/products/custody/v1.34/deployment/install/cold-bridge-deployment)
- [Recover a cold vault](/pt-br/products/custody/v1.34/how-to/recover-cold-vault)