> For the complete documentation index, see [llms.txt](https://docs.liquidcommerce.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.liquidcommerce.cloud/services/users-api/add-payment.md).

# Add Payment

Add a new payment method to a user by ID

## Endpoint Details <a href="#search-catalog" id="search-catalog"></a>

<mark style="color:green;">`POST`</mark> `/users/payments/add`

### Headers

<table><thead><tr><th width="393">Header</th><th>Value</th></tr></thead><tbody><tr><td>Content-Type</td><td><code>application/json</code></td></tr><tr><td>Authorization</td><td><code>Bearer &#x3C;YOUR_ACCESS_TOKEN></code></td></tr></tbody></table>

### Body

<table><thead><tr><th width="214">Parameter</th><th width="165">Type</th><th width="284">Description</th><th data-type="checkbox">Required</th></tr></thead><tbody><tr><td><code>userId</code></td><td>string</td><td>Identifier of the user to add payment method for</td><td>true</td></tr><tr><td><code>paymentMethodId</code></td><td>string</td><td>Payment method ID or new payment token, you must use the <a href="/cloud-sdk/overview.md">CLOUD SDK </a>to mount/inject a paymentElement to be able to generate a payment token.</td><td>true</td></tr><tr><td><code>isDefault</code></td><td>boolean</td><td>Set as default payment method (default: false)</td><td>false</td></tr></tbody></table>

### Response Details

<table><thead><tr><th width="226">Field</th><th width="168">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>statusCode</code></td><td>number</td><td>HTTP status code of the response</td></tr><tr><td><code>message</code></td><td>string</td><td>A brief message describing the result of the API call</td></tr><tr><td><code>metadata</code></td><td><a href="#metadata-object">metaDataObject</a></td><td>Contains metadata about the API call</td></tr><tr><td><code>auth</code></td><td><a href="/authentication-api-integration/get-access-token.md#auth-object">authObject</a></td><td>Authentication object, only when refresh in <code>true</code></td></tr><tr><td><code>data</code></td><td><a href="/types/user.md#userpayment">userPayment</a></td><td>User payment details</td></tr></tbody></table>

#### Metadata Object

<table><thead><tr><th width="144">Field</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>languages</code></td><td>Array&#x3C;string></td><td>List of supported languages for the response, e.g. ["en"]</td></tr><tr><td><code>timestamp</code></td><td>string</td><td>Unix timestamp (in milliseconds) when the response was generated</td></tr><tr><td><code>timezone</code></td><td>string</td><td>Timezone used for the response, always "UTC"</td></tr><tr><td><code>requestId</code></td><td>string</td><td>Unique identifier for the API request. Used for debugging and support</td></tr><tr><td><code>path</code></td><td>string</td><td>API path</td></tr><tr><td><code>version</code></td><td>string</td><td>API version used for the request</td></tr></tbody></table>

### Sample Request and Response

```bash
curl --location 'https://staging.api.liquidcommerce.cloud/users/payments/add' \
--header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
    "customerId": "usrid_123abc456def",
    "paymentMethodId": "paymentid_123abc456def",
    "isDefault": true
}'
```

{% tabs %}
{% tab title="201" %}

```json
{
    "statusCode": 201,
    "message": "Adding an new payment method succeeded",
    "metadata": {
        "languages": [
            "en"
        ],
        "timestamp": 1731625068720,
        "timezone": "UTC",
        "requestId": "requestid_123abc456def",
        "path": "/api/users/payments/add",
        "version": "1.7.0"
    },
    "data": {
        "id": "paymentid_123abc456def",
        "type": "card",
        "isDefault": true,
        "card": {
            "brand": "visa",
            "country": "US",
            "expMonth": 11,
            "expYear": 2031,
            "last4": "1111",
            "funding": "credit"
        },
        "createdAt": "2024-11-14T22:57:49.094Z"
    }
}
```

{% endtab %}
{% endtabs %}
