# Payment Source routes: add, remove

URL: /code/api/payment-source/verbs · Id: `page:code/api/payment-source/verbs`

> The Payment Source Verbs add, remove as api.sb routes, with inputs, result, refusals and an example.

Reference for [Payment Source](/business/nouns/payment-source), one group of [Payment Source routes](/code/api/payment-source).

### PaymentSource.add
Add saves a new Payment Source for a Customer through Stripe’s embedded form on the Startup’s Domain, and can make it the default. [Verb page](/business/nouns/payment-source/add?interface=api).

```text
POST /{namespace}/payment-sources/add
```

Body, as JSON: the inputs. Emits [`PaymentSource.added`](/business/events/PaymentSource.added).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `customer` | [Customer](/business/nouns/customer) | Yes | The Customer who saves it. |
| `kind` | `string` | Yes | How it pays; the form offers only the kinds the Customer’s Market accepts. |
| `default` | `boolean` | No | True to charge it for every new Invoice and renewal. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `paymentSource` | [Payment Source](/business/nouns/payment-source) | Yes | The saved Payment Source; Stripe holds its details. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/payment-sources/add \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"customer":"cus_K1BROJhqzZ","kind":"card"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "paymentSource": {
    "$id": "https://api.sb/leaseline.app/payment-sources/pm_puFT0MuuUM",
    "$type": "PaymentSource",
    "kind": "card",
    "label": "Visa 4242"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "PaymentSource.add",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### PaymentSource.remove
Remove detaches a saved Payment Source so nothing charges it again, and keeps the record. [Verb page](/business/nouns/payment-source/remove?interface=api).

```text
POST /{namespace}/payment-sources/{paymentSource}/remove
```

Path: `paymentSource`. Emits [`PaymentSource.removed`](/business/events/PaymentSource.removed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `paymentSource` | [Payment Source](/business/nouns/payment-source) | Yes | The saved Payment Source. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `paymentSource` | [Payment Source](/business/nouns/payment-source) | Yes | The removed Payment Source, kept on record. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/payment-sources/pm_puFT0MuuUM/remove \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "paymentSource": {
    "$id": "https://api.sb/leaseline.app/payment-sources/pm_puFT0MuuUM",
    "$type": "PaymentSource",
    "kind": "card",
    "label": "Visa 4242"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "PaymentSource.remove",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```