# Variant routes: update, delete

URL: /code/api/variant/records-update · Id: `page:code/api/variant/records-update`

> The Variant Verbs update, delete as api.sb routes, with inputs, result, refusals and an example.

Reference for [Variant](/business/nouns/variant), one group of [Variant routes](/code/api/variant).

### Variant.update
Changes the given properties of a Variant. [Verb page](/business/nouns/variant/update?interface=api).

```text
PATCH /{namespace}/variants/{id}
```

Path: `id`. Body, as JSON: the other inputs. Emits `Variant.updated`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Variant. |
| `key` | `string` | No | The name the Flag returns for it. |
| `value` | `json` | No | What it changes: copy, behavior, a definition Version, or a Thing. |
| `control` | `boolean` | No | True for the current definition every challenger is judged against. |
| `follows` | [Variant](/business/nouns/variant) | No | The Variant it was drafted from by a learn step. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `variant` | [Variant](/business/nouns/variant) | Yes | The Variant. |

**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 PATCH https://api.sb/leaseline.app/variants/variant_nvdfmt7dTw \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value":{}}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "variant": {
    "$id": "https://api.sb/leaseline.app/variants/variant_nvdfmt7dTw",
    "$type": "Variant",
    "key": "Example key",
    "value": {}
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Variant.update",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Variant.delete
Deletes a Variant: a soft delete that keeps its history, undone by `Thing.restore`. [Verb page](/business/nouns/variant/delete?interface=api).

```text
DELETE /{namespace}/variants/{id}
```

Path: `id`. Emits `Variant.deleted`.

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | The id of the Variant. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `variant` | [Variant](/business/nouns/variant) | Yes | The Variant. |

**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 DELETE https://api.sb/leaseline.app/variants/variant_nvdfmt7dTw \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "variant": {
    "$id": "https://api.sb/leaseline.app/variants/variant_nvdfmt7dTw",
    "$type": "Variant",
    "key": "Example key",
    "value": {}
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Variant.delete",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```