# com.atiproto.payment.subscription.create

> Published by [atiproto.com](https://lexicon.garden/identity/did:plc:4x5dcv6u4wlkjcssto7f22nu)

✓ This is the authoritative definition for this NSID.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:4x5dcv6u4wlkjcssto7f22nu/com.atiproto.payment.subscription.create)
- [Documentation](https://lexicon.garden/lexicon/did:plc:4x5dcv6u4wlkjcssto7f22nu/com.atiproto.payment.subscription.create/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:4x5dcv6u4wlkjcssto7f22nu/com.atiproto.payment.subscription.create/examples)

## Definitions

### `com.atiproto.payment.subscription.create`

**Type**: `procedure`

Create a subscription to a user. Returns a one-off cart with checkout URL.

#### Input

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `amount` | `integer` | No | Custom amount in cents (if pay-as-you-want enabled) |
| `cartUri` | `string` (at-uri) | No | AT-URI of an existing cart to add this subscription to. If omitted, a new cart is created. |
| `subject` | `string` (did) | Yes | DID of the user to subscribe to |
| `currency` | `string` | Yes | ISO 4217 currency code |
| `interval` | `string` | Yes | Billing interval |
| `workflow` | `ref` → `com.atiproto.actions#inboundWorkflow` | No | Workflow callback envelope. Present on agent-driven callbacks; absent on initial calls. |
| `isPrivate` | `boolean` | No | If true, the recipient (subject) is stored only in atiproto's private database and is omitted from the PDS subscription record. |
| `redirectUrl` | `string` (uri) | No | URL to redirect to after checkout completes |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `cart` | `ref` → `com.atiproto.cart#view` | No | The created cart record (status: open) |
| `cartUri` | `string` (at-uri) | No | URI of the cart record in PDS |
| `workflow` | `ref` → `com.atiproto.actions#outboundWorkflow` | No | Workflow envelope. When present, the agent runs the actions and calls back. When absent, this is the final native result. |
| `checkoutUrl` | `string` (uri) | No | Checkout URL hosted by atiproto |
| `subscription` | `ref` → `com.atiproto.subscription#view` | No | The created subscription record (status: pending) |
| `subscriptionUri` | `string` (at-uri) | No | URI of the subscription record in PDS |

## Raw Schema

```json
{
  "id": "com.atiproto.payment.subscription.create",
  "defs": {
    "main": {
      "type": "procedure",
      "input": {
        "schema": {
          "type": "object",
          "required": [
            "subject",
            "currency",
            "interval"
          ],
          "properties": {
            "amount": {
              "type": "integer",
              "description": "Custom amount in cents (if pay-as-you-want enabled)"
            },
            "cartUri": {
              "type": "string",
              "format": "at-uri",
              "description": "AT-URI of an existing cart to add this subscription to. If omitted, a new cart is created."
            },
            "subject": {
              "type": "string",
              "format": "did",
              "description": "DID of the user to subscribe to"
            },
            "currency": {
              "type": "string",
              "maxLength": 3,
              "description": "ISO 4217 currency code"
            },
            "interval": {
              "enum": [
                "monthly",
                "yearly"
              ],
              "type": "string",
              "maxLength": 64,
              "description": "Billing interval"
            },
            "workflow": {
              "ref": "com.atiproto.actions#inboundWorkflow",
              "type": "ref",
              "description": "Workflow callback envelope. Present on agent-driven callbacks; absent on initial calls."
            },
            "isPrivate": {
              "type": "boolean",
              "description": "If true, the recipient (subject) is stored only in atiproto's private database and is omitted from the PDS subscription record."
            },
            "redirectUrl": {
              "type": "string",
              "format": "uri",
              "description": "URL to redirect to after checkout completes"
            }
          }
        },
        "encoding": "application/json"
      },
      "output": {
        "schema": {
          "type": "object",
          "properties": {
            "cart": {
              "ref": "com.atiproto.cart#view",
              "type": "ref",
              "description": "The created cart record (status: open)"
            },
            "cartUri": {
              "type": "string",
              "format": "at-uri",
              "description": "URI of the cart record in PDS"
            },
            "workflow": {
              "ref": "com.atiproto.actions#outboundWorkflow",
              "type": "ref",
              "description": "Workflow envelope. When present, the agent runs the actions and calls back. When absent, this is the final native result."
            },
            "checkoutUrl": {
              "type": "string",
              "format": "uri",
              "description": "Checkout URL hosted by atiproto"
            },
            "subscription": {
              "ref": "com.atiproto.subscription#view",
              "type": "ref",
              "description": "The created subscription record (status: pending)"
            },
            "subscriptionUri": {
              "type": "string",
              "format": "at-uri",
              "description": "URI of the subscription record in PDS"
            }
          }
        },
        "encoding": "application/json"
      },
      "description": "Create a subscription to a user. Returns a one-off cart with checkout URL."
    }
  },
  "$type": "com.atproto.lexicon.schema",
  "lexicon": 1
}
```
