> For the complete documentation index, see [llms.txt](https://developer.branta.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.branta.pro/tech/api/v2/adding-payments.md).

# Adding Payments

## POST /payments

>

```json
{"openapi":"3.0.0","info":{"title":"Branta API","version":"2"},"servers":[{"url":"https://staging.guardrail.branta.pro/v2"}],"paths":{"/payments":{"post":{"parameters":[{"in":"header","name":"Authorization","required":true,"schema":{"type":"string"},"description":"`Authorization: Bearer` header with token is required. \n\nKeep your API key confidential."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequest"}}}},"responses":{"201":{"description":"Payment created successfully"},"401":{"description":"Unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Unauthorized"}}}},"422":{"description":"Unprocessable Content","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnprocessableContent"}}}}}}}},"components":{"schemas":{"PaymentRequest":{"type":"object","properties":{"destinations":{"type":"array","items":{"type":"object","properties":{"value":{"type":"string","description":"The payable address."},"type":{"type":"string","enum":["bitcoin_address","bolt11","bolt12","ln_url","tether_address","ln_address","ark_address"],"description":"The type of the destination address."},"zk":{"type":"boolean","description":"If the provided value is encrypted or not. <b>Note</b>: value must be pre-encrypted with `AES-GCM` when this option is set to true."}},"required":["value"]}},"ttl":{"type":"integer","description":"Branta will remove the payment after ttl seconds."},"description":{"type":"string"},"metadata":{"type":"string","description":"Optional stringified JSON to show the user."}},"required":["destinations","ttl"]},"Unauthorized":{"type":"object","properties":{"error":{"type":"string"}}},"UnprocessableContent":{"type":"object","properties":{"destinations":{"type":"string"},"ttl":{"type":"string"}}}}}}
```

## Zero Knowledge

Zero Knowledge requires the API caller to encrypt the destination value before `POST`. Below is a javascript example of the encryption algorithm. Our [SDKs](/tech/sdk.md) wrap the encrypt/decrypt functionality for you, if desired, or can be used for example code.

```javascript
async function encrypt(value, secret) {
  const keyData = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(secret));
  const key = await crypto.subtle.importKey('raw', keyData, { name: 'AES-GCM' }, false, ['encrypt']);

  const iv = crypto.getRandomValues(new Uint8Array(12));
  const encrypted = await crypto.subtle.encrypt(
    { name: 'AES-GCM', iv: iv },
    key,
    new TextEncoder().encode(value)
  );

  const combined = new Uint8Array(iv.length + encrypted.byteLength);
  combined.set(iv, 0);
  combined.set(new Uint8Array(encrypted), iv.length);

  return btoa(String.fromCharCode(...combined));
}
```

```javascript
const address = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa';
const secret = crypto.randomUUID();

await encrypt(address, secret);
// Result:
// LQdBBewrzglmPYwUVoSjBJihA/Br8o+T1ArXGLaAuh7yJiW2dClzSBSUbUH1zhPo1WUBtr7JaFQ7wkK7CG4=
```
