> Solana Developer Platform docs, served as Markdown. The [docs index](https://platform.solana.com/docs.md) lists every page and [llms.txt](https://platform.solana.com/docs/ai/llms.txt) the key ones; [SKILL.md](https://platform.solana.com/SKILL.md) has the rules for building on SDP.

# Prepare subscription authorization

Prepares the subscriber-signed Solana transaction that initializes the subscription authority and subscribes to the plan.

`POST /v1/payments/subscriptions/{subscriptionId}/prepare-authorization`

The transaction must still be signed and submitted by the client. A subscriber that is one of the organization's SDP wallets answers 409: pay from an SDP wallet through a recurring payment.

Requires an [API key](/docs/developing-with-sdp/authentication) with the `recurring.execute` action.

## Path parameters

- **`subscriptionId`** · `string` · required · min length 1 · example `psub_example`

  SDP subscription record ID.

## Headers

- **`x-project-id`** · `string` · min length 1 · example `prj_example`

  Required for dashboard sessions. API keys use their assigned project.

## Request body

`application/json` · required

Inputs for preparing the subscriber-signed Solana subscription authorization transaction.

- **`subscriberTokenAccount`** · `string` · required · example `7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU`

  Subscriber token account that authorizes the subscription authority delegation.

- **`expectedPlanCreatedAt`** · `string` · required · pattern `^\d+$` · example `0`

  Unsigned 64-bit created-at timestamp from the on-chain plan terms that the subscriber consents to.

- **`expectedSubscriptionAuthorityInitId`** · `string` · required · pattern `^-?\d+$` · example `0`

  Signed 64-bit init id from the on-chain subscription authority that the subscriber consents to.

## Responses

- **`200`** Subscription authorization prepared

  - **`data`** · `object` · required

    Prepared subscription authorization response payload.

    - **`subscription`** · `object` · required

      Recurring payment subscription record.

      - **`id`** · `string` · required · example `psub_example`

        SDP subscription ID.

      - **`organizationId`** · `string` · required · min length 1 · example `org_example`

        Organization identifier.

      - **`projectId`** · `string` · required · min length 1 · example `prj_example`

        Project identifier.

      - **`planId`** · `string` · required

        SDP subscription plan ID.

      - **`counterpartyId`** · `string` · required

        Counterparty ID.

      - **`subscriberAddress`** · `string` · required · min length 32 · max length 44 · example `So11111111111111111111111111111111111111112`

        Base58-encoded Solana address.

      - **`subscriberTokenAccount`** · `string | null` · required · min length 32 · max length 44 · example `So11111111111111111111111111111111111111112`

        Subscriber token account address.

      - **`subscriptionPda`** · `string | null` · required · min length 32 · max length 44 · example `So11111111111111111111111111111111111111112`

        On-chain subscription PDA.

      - **`subscriptionAuthorityAddress`** · `string | null` · required · min length 32 · max length 44 · example `So11111111111111111111111111111111111111112`

        On-chain subscription authority address.

      - **`authorizationSignature`** · `string | null` · required

        Customer authorization transaction signature.

      - **`status`** · `string` · required · one of `pending_authorization`, `active`, `paused`, `canceling`, `canceled`, `expired` · example `active`

        Subscription status.

      - **`currentPeriodStartAt`** · `string | null` · required · format `date-time` · example `2025-01-01T00:00:00.000Z`

        ISO 8601 timestamp.

      - **`nextCollectionDueAt`** · `string | null` · required · format `date-time` · example `2025-01-01T00:00:00.000Z`

        ISO 8601 timestamp.

      - **`cancelAt`** · `string | null` · required · format `date-time` · example `2025-01-01T00:00:00.000Z`

        ISO 8601 timestamp.

      - **`canceledAt`** · `string | null` · required · format `date-time` · example `2025-01-01T00:00:00.000Z`

        ISO 8601 timestamp.

      - **`createdBy`** · `string | null` · required

      - **`createdAt`** · `string` · required · format `date-time` · example `2025-01-01T00:00:00.000Z`

        ISO 8601 timestamp.

      - **`updatedAt`** · `string` · required · format `date-time` · example `2025-01-01T00:00:00.000Z`

        ISO 8601 timestamp.

    - **`subscriptionPda`** · `string` · required · min length 32 · max length 44 · example `So11111111111111111111111111111111111111112`

      Derived subscription delegation PDA.

    - **`subscriptionAuthorityAddress`** · `string` · required · min length 32 · max length 44 · example `So11111111111111111111111111111111111111112`

      Derived subscription authority PDA.

    - **`preparedTransaction`** · `object` · required

      Unsigned Solana subscriptions transaction payload for client-side signing.

      - **`serialized`** · `string` · required · min length 1 · example `AQID`

        Base64-encoded unsigned transaction.

      - **`blockhash`** · `string` · required · example `blockhash_example`

        Blockhash for the transaction.

      - **`lastValidBlockHeight`** · `string` · required · example `123456`

        Last valid block height.

      - **`requiredSigners`** · `string[]` · required · each min length 32 · each max length 44 · each example `So11111111111111111111111111111111111111112`

        Addresses that must sign the prepared transaction. This includes the sponsored fee payer when the transaction uses one.

  - **`meta`** · `object` · required

    Response metadata.

    - **`requestId`** · `string` · required · min length 1 · example `req_example`

      Request identifier for tracing.

    - **`timestamp`** · `string` · required · format `date-time` · example `2025-01-01T00:00:00.000Z`

      ISO 8601 timestamp.

- **`400`** Bad Request

  - **`error`** · `object` · required

    Standard error payload.

    - **`code`** · `string` · required

      Machine-readable error code.

    - **`message`** · `string` · required

      Human-readable error message.

    - **`details`** · `object`

      Optional error details for debugging.

      - **`*`** · `any`

  - **`meta`** · `object`

    - **`requestId`** · `string` · min length 1 · example `req_example`

      Request identifier for tracing.

- **`401`** Unauthorized

  Same fields as `400`.

- **`403`** Forbidden. Requires the `recurring.execute` action: an API key must hold it (a module's `manage` or `execute` also covers its `read`), and a signed-in member's organization role must include it. Without it the error is INSUFFICIENT_PERMISSIONS and `error.details.action` names the action. Any other 403 names its own reason.

  Same fields as `400`.

- **`404`** Not Found

  Same fields as `400`.

- **`409`** Conflict

  Same fields as `400`.

- **`500`** Internal Server Error

  Same fields as `400`.

## Example request

```bash tab="cURL"
curl -X POST 'https://api.solana.com/v1/payments/subscriptions/psub_example/prepare-authorization' \
  -H "Authorization: Bearer $SDP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "subscriberTokenAccount": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
    "expectedPlanCreatedAt": "0",
    "expectedSubscriptionAuthorityInitId": "0"
  }'
```

```ts tab="TypeScript"
const res = await fetch("https://api.solana.com/v1/payments/subscriptions/psub_example/prepare-authorization", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SDP_API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    "subscriberTokenAccount": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
    "expectedPlanCreatedAt": "0",
    "expectedSubscriptionAuthorityInitId": "0"
  })
});
```

```python tab="Python"
import os, requests

r = requests.post("https://api.solana.com/v1/payments/subscriptions/psub_example/prepare-authorization",
  headers={"Authorization": f"Bearer {os.environ['SDP_API_KEY']}"},
  json={
    "subscriberTokenAccount": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU",
    "expectedPlanCreatedAt": "0",
    "expectedSubscriptionAuthorityInitId": "0"
  })
```

## Example responses

```json tab="200"
{
  "data": {
    "subscription": {
      "id": "psub_example",
      "organizationId": "org_example",
      "projectId": "prj_example",
      "planId": "plan_example",
      "counterpartyId": "counterparty_example",
      "subscriberAddress": "So11111111111111111111111111111111111111112",
      "subscriberTokenAccount": "So11111111111111111111111111111111111111112",
      "subscriptionPda": "So11111111111111111111111111111111111111112",
      "subscriptionAuthorityAddress": "So11111111111111111111111111111111111111112",
      "authorizationSignature": "example",
      "status": "active",
      "currentPeriodStartAt": "2025-01-01T00:00:00.000Z",
      "nextCollectionDueAt": "2025-01-01T00:00:00.000Z",
      "cancelAt": "2025-01-01T00:00:00.000Z",
      "canceledAt": "2025-01-01T00:00:00.000Z",
      "createdBy": "example",
      "createdAt": "2025-01-01T00:00:00.000Z",
      "updatedAt": "2025-01-01T00:00:00.000Z"
    },
    "subscriptionPda": "So11111111111111111111111111111111111111112",
    "subscriptionAuthorityAddress": "So11111111111111111111111111111111111111112",
    "preparedTransaction": {
      "serialized": "AQID",
      "blockhash": "blockhash_example",
      "lastValidBlockHeight": "123456",
      "requiredSigners": [
        "So11111111111111111111111111111111111111112"
      ]
    }
  },
  "meta": {
    "requestId": "req_example",
    "timestamp": "2025-01-01T00:00:00.000Z"
  }
}
```

```json tab="403"
{
  "error": {
    "code": "INSUFFICIENT_PERMISSIONS",
    "message": "Missing action: recurring.execute",
    "details": {
      "action": "recurring.execute"
    }
  },
  "meta": {
    "requestId": "req_example"
  }
}
```

Error responses use the [standard error shape](/docs/reference/conventions/errors).
