# Set seller billing plan

- Sandbox: `POST https://sandbox.payme.io/api/partner/api/sellers/set-plan`
- Production: `POST https://live.payme.io/api/partner/api/sellers/set-plan`

## Credentials

- Header `Authorization: Bearer <token>`

Assign a billing plan to a seller with payer-based activation flow.

**Payer modes:**
- `partner` — Plan is activated immediately (no credit card required).
- `seller` — If the seller already has a credit card on file, the plan is activated immediately. If not, a credit card URL is returned and the plan activates once the seller completes payment.

> **Note:** `callBackUrl` is not yet implemented and will be ignored.

## Parameters

This endpoint takes no path, query or header parameters.

## Request body

Content type: `application/json`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `sellerId` | string | yes | Seller identifier (UUID, MPL ID, email, or socialId) |
| `planId` | string | yes | Plan identifier to assign |
| `payer` | string | yes | Who pays for the plan. 'partner' = immediate activation, 'seller' = may require credit card. |

### Request example

```json
{
  "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
  "planId": "3d653770-6376-40a5-b98e-17c598f1d7d8",
  "payer": "partner"
}
```

## Code samples

### curl

```bash
curl -X POST 'https://sandbox.payme.io/api/partner/api/sellers/set-plan' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <YOUR_TOKEN>' \
  --data-raw '{
  "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
  "planId": "3d653770-6376-40a5-b98e-17c598f1d7d8",
  "payer": "partner"
}'
```

### Node.js

```javascript
const response = await fetch("https://sandbox.payme.io/api/partner/api/sellers/set-plan", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <YOUR_TOKEN>",
  },
  body: JSON.stringify({
    "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
    "planId": "3d653770-6376-40a5-b98e-17c598f1d7d8",
    "payer": "partner"
  }),
});

console.log(await response.text());
```

### Python

```python
import requests

response = requests.post(
    "https://sandbox.payme.io/api/partner/api/sellers/set-plan",
    headers={
        "Authorization": "Bearer <YOUR_TOKEN>",
    },
    json={
        "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
        "planId": "3d653770-6376-40a5-b98e-17c598f1d7d8",
        "payer": "partner",
    },
)

print(response.text)
```

### PHP

```php
<?php

$body = <<<'BODY'
{
  "sellerId": "a6a9700f-8571-4f9b-bfae-ba943fb96982",
  "planId": "3d653770-6376-40a5-b98e-17c598f1d7d8",
  "payer": "partner"
}
BODY;

$ch = curl_init('https://sandbox.payme.io/api/partner/api/sellers/set-plan');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'Authorization: Bearer <YOUR_TOKEN>',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
```

## Responses

### 200 — Plan set successfully (success)

| Field | Type | Description |
| --- | --- | --- |
| `payload` | object |  |
| `payload.status` | string | 'activated' when plan is active immediately, 'pending' when seller must complete payment first. |
| `payload.message` | string | Human-readable message (present when status is 'pending') |
| `payload.creditCardUrl` | string | URL for seller to submit credit card details (present when status is 'pending') |

```json
{
  "payload": {
    "status": "activated"
  }
}
```

### 400 — Bad Request (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 400,
  "message": [
    "Validation failed"
  ],
  "error": "Bad Request"
}
```

### 401 — Unauthorized (error)

| Field | Type | Description |
| --- | --- | --- |
| `error` | string |  |
| `error_description` | string |  |

```json
{
  "error": "unauthorized_client",
  "error_description": "Client authentication failed"
}
```

### 404 — Seller or plan not found (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 404,
  "message": "Seller not found",
  "error": "Not Found"
}
```

### 422 — Unprocessable Entity (error)

| Field | Type | Description |
| --- | --- | --- |
| `statusCode` | integer | HTTP status code |
| `message` | string | Error message(s) |
| `error` | string | Error type |

```json
{
  "statusCode": 422,
  "message": "Bad seller configuration. Please contact support!",
  "error": "Unprocessable Entity"
}
```
