Overview

Clients can allocate assets from their Go Network account to their account on your platform. When clients allocate assets, BitGo sends you an allocation request that includes an allocation ID.

Using the allocation ID, you must respond to allocation requests with a reserved or rejected result:

  • If no allocation exists, create a new reserved allocation in the client's account on your platform.
  • If an allocation already exists or you rejected it, return the current status.
  • If an allocation is already released or cleared, return 200 as described in the Allocations section below.
  • To reject an allocation, return 200 with rejectionReason set. Don't use a 4xx response to reject.

Note

This endpoint doesn't credit the client account. It only creates a reserved allocation within your platform that can be cleared (confirmed) by BitGo during deallocation or trade settlement.

Prerequisites

API Specifications

Use the following to build endpoints that BitGo can send requests to for processing allocations.

Allocations

Route: POST /bitgo/v1/allocations

This endpoint must:

  • Respond with a 200 if the allocation is already released. Additional assets should be reserved.
  • Respond with a 200, idempotently, if the allocation is already cleared. No additional assets should be reserved.
  • Put the amount requested in a reserved state that can be credited (confirmed and cleared) or canceled (released) using the PUT endpoint.
  • Take an allocationId in the event of a retry, so that you don't act on the same allocation twice. The endpoint should be idempotent.
    • Return the previously rejected state, if you rejected the allocation prior.
    • Return the previously approved state, if you approved the allocation prior.
  • Be able to guard against racing requests.

Request Headers

Header Type Description
X-BitGo-Signature string The signature BitGo provides using a private/public key pair.

Request Body

Parameter Type Description
allocationId UUID The BitGo ID for the allocation.
amount currency: string, quantity: string The currency type and currency amount to allocate.
clientId UUID The BitGo ID for the user on your system.
connectionId UUID The ID of the connection.
partnersConnectionId string The ID of your partner account tied to the connection.
partnersClientId string The ID of the user in your system.

200 Response

Response Field Type Description
allocationId UUID The BitGo ID for the allocation.
amount currency: string, quantity: string The currency type and currency amount to allocate.
clientId UUID The BitGo ID for the user on your system.
connectionId UUID The ID of the connection.
partnersClientId string The ID for the user on your system.
partnersConnectionId string The ID of your partner account tied to the connection.
partnersAllocationId string The ID for the allocation on your system.
rejectionReason? string The reason for a rejection. The standardized value is “Unsupported currency”

Note

BitGo displays the rejectionReason? to the user who requested the allocation.

Error Responses

All error responses use the same body, { "error": string }.

Status Return when error value
400 The request is malformed or fails validation. A description of the error.
401 The X-BitGo-Signature header is missing or fails verification. A description of the error.
500 An unexpected failure occurs on your platform. A description of the error.

Clear allocation

Route: PUT /bitgo/v1/allocation/:allocationId/clear

This endpoint must:

  • Issue a 404 response, stating Allocation not found, if you have no record of the allocation or deallocation in your system. BitGo checks for this response during the failure remediation process.
  • Issue a 404 response if BitGo calls a put on an allocation that isn’t in the reserved status on your system.
  • Issue a 409 response if BitGo is attempting to update status to cleared, on an already released allocation.
  • Take an allocationId in the event of failure remediation, so that you don't act on the same allocation twice. The endpoint should be idempotent.
  • Not credit the client a second time if the allocation is already cleared.
  • Be able to guard against racing requests.

Path Parameters

Parameter Type Description
allocationId UUID The BitGo ID for the allocation to clear. The request has no body.

Request Headers

Header Type Description
X-BitGo-Signature string The signature BitGo provides using a private/public key pair.

200 Response

Response Field Type Description
allocationId UUID The BitGo ID for the allocation.
amount currency: string, quantity: string The currency type and currency amount to allocate.
clientId UUID The BitGo ID for the user on your system.
connectionId UUID The ID of the connection.
partnersClientId string The ID for the user on your system.
partnersConnectionId string The ID of your partner account tied to the connection.
partnersAllocationId string The ID for the allocation on your system.

Error Responses

All error responses use the same body, { "error": string }.

Status Return when error value
400 The request is malformed or fails validation. A description of the error.
401 The X-BitGo-Signature header is missing or fails verification. A description of the error.
404 You have no record of the allocation or deallocation, or the allocation isn’t in the reserved status. Must be exactly Allocation not found.
409 BitGo tries to clear an allocation that is already released. A description of the conflict.
500 An unexpected failure occurs on your platform. A description of the error.

1. Reserve Assets

BitGo sends you the following request for each client-initiated allocation:

POST /bitgo/v1/allocations

Request Body
{
    "allocationId": "2f1c9a3e-6b1d-4c1e-9d7a-3a5b8c0e1f42",
    // Amount in base units. For example, satoshis.
    "amount": { "currency": "ofcbtc", "quantity": "100000" },
    "clientId": "7d9e4b52-1a3c-4f60-8b2d-5e6f7a8b9c01",
    "connectionId": "c3a1e8d4-9b27-4d5f-a6e0-1b2c3d4e5f60",
    "partnersConnectionId": "<your-connection-id>",
    "partnersClientId": "<your-client-id>"
}

You put the requested amount into a RESERVED state that you can then credit (confirm or clear) once you release the assets in the following step.

Respond with a 200 and the following body. To reject the allocation, also include rejectionReason:

{
    "allocationId": "2f1c9a3e-6b1d-4c1e-9d7a-3a5b8c0e1f42",
    "amount": { "currency": "ofcbtc", "quantity": "100000" },
    "clientId": "7d9e4b52-1a3c-4f60-8b2d-5e6f7a8b9c01",
    "connectionId": "c3a1e8d4-9b27-4d5f-a6e0-1b2c3d4e5f60",
    "partnersConnectionId": "<your-connection-id>",
    "partnersClientId": "<your-client-id>",
    "partnersAllocationId": "<your-allocation-id>"
}

2. Clear Assets

BitGo sends you the following PUT call, notifying you that it's now safe to credit the client's account with the reserved assets. This enables clients to trade their allocated assets on your platform.

PUT /bitgo/v1/allocation/{allocationId}/clear

Clients can now trade their allocated assets on your platform.

Respond with a 200 and the following body:

{
    "allocationId": "2f1c9a3e-6b1d-4c1e-9d7a-3a5b8c0e1f42",
    "amount": { "currency": "ofcbtc", "quantity": "100000" },
    "clientId": "7d9e4b52-1a3c-4f60-8b2d-5e6f7a8b9c01",
    "connectionId": "c3a1e8d4-9b27-4d5f-a6e0-1b2c3d4e5f60",
    "partnersConnectionId": "<your-connection-id>",
    "partnersClientId": "<your-client-id>",
    "partnersAllocationId": "<your-allocation-id>"
}

3. Report Allocation Status to BitGo (Async Partners Only)

Endpoint: Update Partner Allocations

This step applies only to partners with async allocations enabled. In an async flow, your endpoint in Step 1 returns a reserved state immediately, and BitGo does not call /clear. Instead, your platform processes the allocation asynchronously and reports the final status back to BitGo using this endpoint.

Call this endpoint after you process the allocation on your platform:

  • Set status to cleared when you credit the client's account and confirm the allocation.
  • Set status to released when the allocation cannot be processed and must be reversed. Include rejectReason when releasing.

Note

When you report the status back to BitGo the allocation reaches a terminal state and can't be updated further.

The request body must be cryptographically signed. See Request Signing and Verification.

export ENTERPRISE_ID="<YOUR_ENTERPRISE_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"

curl -X PUT \
  https://app.bitgo-test.com/api/network/v1/enterprises/$ENTERPRISE_ID/partners/allocations \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "allocationId": "<bitgo-allocation-uuid>",
    "status": "cleared",
    "amount": {
      "currency": "ofcbtc",
      "quantity": "100000"
    },
    "clientId": "<bitgo-client-uuid>",
    "connectionId": "<bitgo-connection-uuid>",
    "partnersClientId": "<your-client-id>",
    "partnersConnectionId": "<your-connection-id>",
    "partnersAllocationId": "<your-allocation-id>",
    "nonce": "<unique-nonce>",
    "payload": "<stringified payload>",
    "signature": "<signature>"
  }'

To release an allocation, set status to released and include a rejectReason:

curl -X PUT \
  https://app.bitgo-test.com/api/network/v1/enterprises/$ENTERPRISE_ID/partners/allocations \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -d '{
    "allocationId": "<bitgo-allocation-uuid>",
    "status": "released",
    "rejectReason": "Unsupported currency",
    "amount": {
      "currency": "ofcbtc",
      "quantity": "100000"
    },
    "clientId": "<bitgo-client-uuid>",
    "connectionId": "<bitgo-connection-uuid>",
    "partnersClientId": "<your-client-id>",
    "partnersConnectionId": "<your-connection-id>",
    "partnersAllocationId": "<your-allocation-id>",
    "nonce": "<unique-nonce>",
    "payload": "<stringified payload>",
    "signature": "<signature>"
  }'

Step Result

{
  "allocationId": "<bitgo-allocation-uuid>",
  "amount": {
    "currency": "ofcbtc",
    "quantity": "100000"
  },
  "clientId": "<bitgo-client-uuid>",
  "connectionId": "<bitgo-connection-uuid>",
  "partnersClientId": "<your-client-id>",
  "partnersConnectionId": "<your-connection-id>",
  "partnersAllocationId": "<your-allocation-id>"
}

Next

Create Settlements