# POST

### Payments <a href="#payments" id="payments"></a>

#### `POST /payments/external_accounts` <a href="#post-payments-external_accounts" id="post-payments-external_accounts"></a>

```
const createExternalAccount = () => {
  const timestamp = Math.round(Date.now() / 1000)
  const body = {
    participant_code: 'ALI123',
    account_nickname: 'test1',
    account_number: '123456789',
    routing_number: '011401533',
    account_type: 'checking'
  }
  const payload = timestamp + 'POST' + '/payments/external_accounts' + JSON.stringify(body)
  const decodedSecret = Buffer.from(apiSecret, 'base64')
  const hmac = crypto.createHmac('sha256', decodedSecret)
  const signedPayload = hmac.update(payload).digest('base64')

  // SET HEADERS
  const headers = {
    'X-NDAX-API-KEY': 'public_key',
    'X-NDAX-SIGNED': signedPayload,
    'X-NDAX-TIMESTAMP': timestamp,
    'X-NDAX-PASSPHRASE': 'passphrase'
  }
  const options = {
    headers,
    body,
    json: true
  }

  return request.post(`https://api.ndax.in/payments/external_accounts`, options)
}
```

> Sample response

```
{
  "request_id": "0f68333e-2114-469d-b505-c850d776e063",
  "participant_code": "ALI123",
  "platform_code": "TES123",
  "account_nickname": "test1",
  "account_type": "checking",
  "external_account_id": "0f68333e-2114-469d-b505-c850d776e063",
  "created_at": "1975-08-19T23:15:30.000Z"
}
```

Creates a new external account object that is required when generating payment transactions.

Request body:

<table><thead><tr><th width="202.33333333333331">Parameter</th><th width="446">Description</th><th>Type</th></tr></thead><tbody><tr><td>participant_code</td><td>The participant code of the Platform’s participant that the external account will be associated with.</td><td>string</td></tr><tr><td>account_nickname</td><td>The account nickname of the external account, i.e. “Primary Checking”</td><td>string</td></tr><tr><td>account_number</td><td>The full bank account number of the external account.</td><td>string</td></tr><tr><td>routing_number</td><td>The routing number of the bank where the external account is held.</td><td>string</td></tr><tr><td>account_type</td><td>Either “checking” or “savings” and indicates what type of account the external account is.</td><td>string</td></tr></tbody></table>

Additional fields in response:

<table><thead><tr><th width="216.33333333333331">Parameter</th><th width="418">Description</th><th>Type</th></tr></thead><tbody><tr><td>external_account_id</td><td>The unique identifier that NDAX generates to identify the external account.</td><td>string</td></tr></tbody></table>

#### `GET /payments/external_accounts` <a href="#get-payments-external_accounts" id="get-payments-external_accounts"></a>

```
const getExternalAccounts = () => {
  const timestamp = Math.round(Date.now() / 1000)
  const participantCodes = 'ALI123,TES123'
  const payload = `${timestamp}GET/payments/external_accounts?participants=${participantCodes}&page=1&size=20{}`
  const decodedSecret = Buffer.from(apiSecret, 'base64')
  const hmac = crypto.createHmac('sha256', decodedSecret)
  const signedPayload = hmac.update(payload).digest('base64')

  // SET HEADERS
  const headers = {
    'X-SCX-API-KEY': 'public_key',
    'X-SCX-SIGNED': signedPayload,
    'X-SCX-TIMESTAMP': timestamp,
    'X-SCX-PASSPHRASE': 'passphrase'
  }
  const options = {
    headers,
    json: true
  }

  return request.get(`https://api.ndax.in/payments/external_accounts?participants=ALI123,TES123&page=1&size=20`, options)
}
```

> Sample response

```
{
  "message": [
    {
      "request_id": "0f68333e-2114-469d-b505-c850d776e063",
      "account_number": "123456789",
      "routing_number": "011401533",
      "participant_code": "ALI123",
      "platform_code": "TES123",
      "account_nickname": "test1",
      "account_type": "checking",
      "external_account_id": "0f68333e-2114-469d-b505-c850d776e063",
      "created_at": "1975-08-19T23:15:30.000Z",
      "updated_at": "1975-08-19T23:15:30.000Z"
    }
  ],
  "page": 1,
  "total_pages": 1,
  "page_size": 20,
  "count": 10
}
```

Used to get a list of external\_accounts associated with a Platform’s participants.

Query parameters include:

* `participants` (optional) list of participant codes that can be used to filter for external accounts, example: ALI123,TES123.
* `page` (optional) for paginating through the list of accounts.
* `size` (optional) for paginating through the list of accounts.

Response:

<table><thead><tr><th width="201.33333333333331">Parameter</th><th width="479">Description</th><th>Type</th></tr></thead><tbody><tr><td>request_id</td><td>The unique identifier generated by NDAX associated with the request.</td><td>string</td></tr><tr><td>participant_code</td><td>The participant code of the Platform’s participant that the external account will be associated with.</td><td>string</td></tr><tr><td>account_nickname</td><td>The account nickname of the external account, i.e. “Primary Checking”</td><td>string</td></tr><tr><td>account_number</td><td>The full bank account number of the external account.</td><td>string</td></tr><tr><td>routing_number</td><td>The routing number of the bank where the external account is held.</td><td>string</td></tr><tr><td>account_type</td><td>Accepts either “checking” or “savings” and indicates what type of account the external account is.</td><td>string</td></tr><tr><td>external_account_id</td><td>The unique identifier that NDAX generates to identify the external account.</td><td>string</td></tr></tbody></table>
