> 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=
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developer.branta.pro/tech/api/v2/adding-payments.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
