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

# Get Custody Contract

> Resolve the external securities custody contract for your network

Returns the `TRexCustody` address your instance settles through, resolved from the network your API key is bound to. There is one contract per network and it is the same for every issuer on that network.

Ask for it rather than hardcoding it. The address differs between the test and production networks, and a book created against the wrong one is rejected with `INVALID_CONFIG`.

`available` is `false` when no custody contract is deployed on your instance's network yet. Creating a book on that network then returns `503 CUSTODY_NOT_DEPLOYED`.

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="custodyContract" type="string">
      The custody contract address, lower-cased, or `null` when none is deployed.
    </ResponseField>

    <ResponseField name="instanceType" type="string">
      `DEVELOPMENT` or `PRODUCTION`, the network class your key resolves to.
    </ResponseField>

    <ResponseField name="available" type="boolean">
      Whether a contract address was resolved.
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.trusset.org/orderbooks/external-securities/api/custody-contract" \
    -H "X-API-Key: trusset_your_key_here"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    'https://api.trusset.org/orderbooks/external-securities/api/custody-contract',
    { headers: { 'X-API-Key': 'trusset_your_key_here' } }
  );
  const { data } = await res.json();

  if (!data.available) throw new Error('external securities custody is not deployed on this network');
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "custodyContract": "0x489aee4ae9546081d55848f157e03192e826988c",
      "instanceType": "DEVELOPMENT",
      "available": true
    }
  }
  ```

  ```json Response - Not Deployed theme={null}
  {
    "success": true,
    "data": {
      "custodyContract": null,
      "instanceType": "PRODUCTION",
      "available": false
    }
  }
  ```
</ResponseExample>

## Error Codes

| Code                  | HTTP  | Cause                                               |
| --------------------- | ----- | --------------------------------------------------- |
| `SERVICE_NOT_ENABLED` | `403` | The Trading service is not enabled on this instance |
