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

# Upsert Payment Account

> Encrypt and store provider credentials (currently Netopia).

## Method

`POST` `/v1/payments/accounts/upsert`

## Body Parameters

<ParamField name="provider" type="string" required>Provider slug (`netopia`).</ParamField>
<ParamField name="displayName" type="string">Friendly name shown in internal tooling.</ParamField>
<ParamField name="liveMode" type="boolean">`true` for production credentials, `false` for sandbox.</ParamField>
<ParamField name="status" type="string">Initial status (`pending`, `active`, `error`). Defaults to `pending`.</ParamField>
<ParamField name="config.posSignature" type="string" required>Netopia POS signature.</ParamField>
<ParamField name="config.apiKey" type="string" required>Netopia API key.</ParamField>

## Headers

<ParamField header="Authorization" type="string">Bearer token (requires `payments:write`).</ParamField>
<ParamField header="content-type" type="string">`application/json`</ParamField>

## Request Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.voyantcloud.com/v1/payments/accounts/upsert \
    -H "Authorization: Bearer $VOYANT_API_KEY" \
    -H "content-type: application/json" \
    -d '{
      "provider": "netopia",
      "displayName": "Netopia LIVE",
      "liveMode": true,
      "config": {
        "posSignature": "xxxx-xxxx-xxxx",
        "apiKey": "secret-api-key"
      }
    }'
  ```

  ```javascript Node.js theme={null}
  await fetch("https://api.voyantcloud.com/v1/payments/accounts/upsert", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.VOYANT_API_KEY}`,
      "content-type": "application/json",
    },
    body: JSON.stringify({
      provider: "netopia",
      displayName: "Netopia Sandbox",
      liveMode: false,
      config: {
        posSignature: process.env.NETOPIA_POS_SIGNATURE!,
        apiKey: process.env.NETOPIA_API_KEY!,
      },
    }),
  })
  ```

  ```python Python theme={null}
  import os, requests

  payload = {
    "provider": "netopia",
    "displayName": "Netopia Sandbox",
    "liveMode": False,
    "config": {
      "posSignature": os.environ["NETOPIA_POS_SIGNATURE"],
      "apiKey": os.environ["NETOPIA_API_KEY"],
    },
  }

  resp = requests.post(
    "https://api.voyantcloud.com/v1/payments/accounts/upsert",
    headers={
      "Authorization": f"Bearer {os.environ['VOYANT_API_KEY']}",
      "content-type": "application/json",
    },
    json=payload,
  )
  account = resp.json()
  ```
</RequestExample>

## Response

<ResponseExample>
  ```json 200 OK theme={null}
  { "id": "payacct_123" }
  ```
</ResponseExample>

<Warning>The endpoint encrypts credentials using Cloud KMS. Configure `GCP_SERVICE_ACCOUNT_KEY` + `GCP_KMS_INTEGRATIONS_KEY_NAME` (or `KMS_ENCRYPTION_KEY` for development) before upserting accounts. Without encryption keys the API returns `501`.</Warning>
