# Service routes: close, open, pause, setCapacity

URL: /code/api/service/verbs · Id: `page:code/api/service/verbs`

> The Service Verbs close, open, pause, setCapacity as api.sb routes, with inputs, result, refusals and an example.

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

### Service.close
Close stops a Service taking new Orders for good, while every placed Order runs to its end. [Verb page](/business/nouns/service/close?interface=api).

```text
POST /{namespace}/services/{service}/close
```

Path: `service`. Body, as JSON: the other inputs. Emits [`Service.closed`](/business/events/Service.closed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The Service to close. |
| `reason` | `text` | Yes | Why it closes. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The closed Service. |

**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. |
| `service` is missing, or is not a service | [`invalid-input`](/code/api/errors/invalid-input) | Send `service` as a service, then call it again. | None. |
| `reason` is missing, or is not a text | [`invalid-input`](/code/api/errors/invalid-input) | Send `reason` as a text, then call it again. | None. |
| The `Idempotency-Key` was sent before with another operation or other input | [`idempotency-mismatch`](/code/api/errors/idempotency-mismatch) | Send a new key for new input; reuse a key only to retry the same request. | None. |

**Example**

```bash
curl -X POST https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW/close \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: catalogmend-service-close-1" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Example reason"}'
```

```json
{
  "api": "https://api.sb/catalogmend.com",
  "service": {
    "$id": "https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW",
    "$type": "Service",
    "name": "Catalogmend",
    "promise": "Every listing error fixed or explained within 48 hours.",
    "status": "draft"
  },
  "action": {
    "$id": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc",
    "operation": "Service.close",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc"
  }
}
```

### Service.open
Open starts a Service taking new Orders on every published Offer that sells it. [Verb page](/business/nouns/service/open?interface=api).

```text
POST /{namespace}/services/{service}/open
```

Path: `service`. Emits [`Service.opened`](/business/events/Service.opened).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The Service to open. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The Service, now taking new Orders. |

**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. |
| `service` is missing, or is not a service | [`invalid-input`](/code/api/errors/invalid-input) | Send `service` as a service, then call it again. | None. |
| The `Idempotency-Key` was sent before with another operation or other input | [`idempotency-mismatch`](/code/api/errors/idempotency-mismatch) | Send a new key for new input; reuse a key only to retry the same request. | None. |

**Example**

```bash
curl -X POST https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW/open \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: catalogmend-service-open-1"
```

```json
{
  "api": "https://api.sb/catalogmend.com",
  "service": {
    "$id": "https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW",
    "$type": "Service",
    "name": "Catalogmend",
    "promise": "Every listing error fixed or explained within 48 hours.",
    "status": "draft"
  },
  "action": {
    "$id": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc",
    "operation": "Service.open",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc"
  }
}
```

### Service.pause
Pause stops a Service taking new Orders until a stated time, while every placed Order runs to its end. [Verb page](/business/nouns/service/pause?interface=api).

```text
POST /{namespace}/services/{service}/pause
```

Path: `service`. Body, as JSON: the other inputs. Emits [`Service.paused`](/business/events/Service.paused).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The Service to pause. |
| `reason` | `text` | Yes | Why it pauses, shown to buyers. |
| `until` | `datetime` | No | When it reopens on its own. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The paused Service. |

**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. |
| `service` is missing, or is not a service | [`invalid-input`](/code/api/errors/invalid-input) | Send `service` as a service, then call it again. | None. |
| `reason` is missing, or is not a text | [`invalid-input`](/code/api/errors/invalid-input) | Send `reason` as a text, then call it again. | None. |
| The `Idempotency-Key` was sent before with another operation or other input | [`idempotency-mismatch`](/code/api/errors/idempotency-mismatch) | Send a new key for new input; reuse a key only to retry the same request. | None. |

**Example**

```bash
curl -X POST https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW/pause \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: catalogmend-service-pause-1" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Example reason"}'
```

```json
{
  "api": "https://api.sb/catalogmend.com",
  "service": {
    "$id": "https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW",
    "$type": "Service",
    "name": "Catalogmend",
    "promise": "Every listing error fixed or explained within 48 hours.",
    "status": "draft"
  },
  "action": {
    "$id": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc",
    "operation": "Service.pause",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc"
  }
}
```

### Service.setCapacity
SetCapacity sets the most work a Service holds in flight, in the unit its intake counts. [Verb page](/business/nouns/service/set-capacity?interface=api).

```text
POST /{namespace}/services/{service}/setCapacity
```

Path: `service`. Body, as JSON: the other inputs. Emits [`Service.capacitySet`](/business/events/Service.capacitySet).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The Service. |
| `capacity` | `integer` | Yes | The most work in flight, in the intake’s unit, such as listings. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `service` | [Service](/business/nouns/service) | Yes | The Service with its new capacity. |

**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. |
| `service` is missing, or is not a service | [`invalid-input`](/code/api/errors/invalid-input) | Send `service` as a service, then call it again. | None. |
| `capacity` is missing, or is not a integer | [`invalid-input`](/code/api/errors/invalid-input) | Send `capacity` as a integer, then call it again. | None. |
| The `Idempotency-Key` was sent before with another operation or other input | [`idempotency-mismatch`](/code/api/errors/idempotency-mismatch) | Send a new key for new input; reuse a key only to retry the same request. | None. |

**Example**

```bash
curl -X POST https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW/setCapacity \
  -H "Authorization: Bearer $SB_TOKEN" \
  -H "Idempotency-Key: catalogmend-service-set-capacity-1" \
  -H "Content-Type: application/json" \
  -d '{"capacity":1}'
```

```json
{
  "api": "https://api.sb/catalogmend.com",
  "service": {
    "$id": "https://api.sb/catalogmend.com/services/service_Eq1ssq4AOW",
    "$type": "Service",
    "name": "Catalogmend",
    "promise": "Every listing error fixed or explained within 48 hours.",
    "status": "draft"
  },
  "action": {
    "$id": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc",
    "operation": "Service.setCapacity",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/catalogmend.com/actions/act_ZY4jDpkbtc"
  }
}
```