---
title: Add a resource requirement to a service
description: "Attaches a requirement: exactly one of category (\"quantity N from this pool\") or resource_id (\"this specific resource\") — both or neither is 422..."
api_method: POST
api_path: "/v1/services/{serviceId}/resource-requirements"
canonical_url: https://wiblo.app/docs/developers/api/resources/create-service-resource-requirement
last_updated: 2026-07-28T18:08:25+02:00
md_url: https://wiblo.app/docs/developers/api/resources/create-service-resource-requirement.md
---

# Add a resource requirement to a service

`POST /v1/services/{serviceId}/resource-requirements`

Attaches a requirement: exactly one of `category` ("quantity N from this pool") or `resource_id` ("this specific resource") — both or neither is 422 `REQUIREMENT_TARGET_INVALID`, and a specific resource takes quantity 1 (422 `REQUIREMENT_QUANTITY_INVALID`). A `resource_id` from another workspace collapses onto 404 `RESOURCE_NOT_FOUND`; a duplicate target for the same service is 409 `REQUIREMENT_ALREADY_EXISTS`. Owner/admin only. Per-user rate-limited at 60/60s.

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `serviceId` | `string` | Yes |  |

## Headers

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `X-Wiblo-Workspace` | `string` | Yes | Workspace id the call is scoped to. The actor must hold an active membership in it; a foreign or unknown id collapses onto 404 WORKSPACE_NOT_FOUND. |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `category` | `string \| null` | No | Resource category to draw from; exactly one of `category` and `resource_id` must be set. |
| `resource_id` | `string \| null` | No | A specific resource the service needs; exactly one of `category` and `resource_id` must be set. |
| `quantity` | `integer` | No | How many distinct free resources the category's pool must supply per booking; must be `1` for a specific-resource requirement. Defaults to `1`. |

## Request

**curl**

```bash
curl https://api.wiblo.app/v1/services/3f8a2b9c-51d4-4e0b-9c6a-7d2e8f1a4b5c/resource-requirements \
  -X POST \
  -H "Authorization: Bearer $WIBLO_TOKEN" \
  -H "X-Wiblo-Workspace: $WIBLO_WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "category": "equipment",
  "quantity": 1
}'
```

**TypeScript**

```ts
import { createSdk, createServiceResourceRequirement } from "@workspace/sdk"

const sdk = createSdk({ baseUrl: "https://api.wiblo.app" })

const { data, error } = await createServiceResourceRequirement({
  client: sdk,
  path: { serviceId: "3f8a2b9c-51d4-4e0b-9c6a-7d2e8f1a4b5c" },
  headers: { "X-Wiblo-Workspace": "..." },
  body: {
    "category": "equipment",
    "quantity": 1
  },
})
```

## Example response

```json
{
  "id": "f1d7a3c9-5e8b-4a1f-9c6d-2b8e4f7a1c3d",
  "workspace_id": "9c1b7e24-6a3f-4d58-b2e9-0f4a8c6d1e37",
  "service_id": "3f8a2b9c-51d4-4e0b-9c6a-7d2e8f1a4b5c",
  "resource_id": null,
  "category": "equipment",
  "quantity": 1,
  "created_at": "2026-07-28T09:12:00.000Z",
  "updated_at": "2026-07-28T09:12:00.000Z"
}
```

## Responses

**`201`** — Requirement created. Returns `ResourceRequirementResponse`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | `string` | Yes | Unique id of the requirement. |
| `workspace_id` | `string` | Yes | Workspace the requirement belongs to. |
| `service_id` | `string` | Yes | Service the requirement is attached to. |
| `resource_id` | `string \| null` | Yes | The specific resource required; `null` for a category requirement. |
| `category` | `string \| null` | Yes | The category pool drawn from; `null` for a specific-resource requirement. |
| `quantity` | `integer` | Yes | How many distinct free resources the category's pool must supply per booking; always `1` for a specific-resource requirement. |
| `created_at` | `string` | Yes | Creation timestamp (RFC 3339). |
| `updated_at` | `string` | Yes | Last-update timestamp (RFC 3339). |

**`400`** — Body failed Zod validation (`VALIDATION_FAILED`). Returns `ApiErrorEnvelope`.

**`401`** — No valid session cookie or `wbl_*` bearer was present. Returns `ApiErrorEnvelope`.

**`403`** — The actor is a plain member; owner or admin is required (`ADMIN_REQUIRED`). Returns `ApiErrorEnvelope`.

**`404`** — The service or the named resource collapsed (`SERVICE_NOT_FOUND` / `RESOURCE_NOT_FOUND` / `WORKSPACE_NOT_FOUND`). Returns `ApiErrorEnvelope`.

**`409`** — The service already requires this category or resource (`REQUIREMENT_ALREADY_EXISTS`). Returns `ApiErrorEnvelope`.

**`422`** — Not exactly one of `category` / `resource_id` (`REQUIREMENT_TARGET_INVALID`), quantity above 1 on a specific resource (`REQUIREMENT_QUANTITY_INVALID`), or a path param failed UUID validation (`INVALID_PARAMS`). Returns `ApiErrorEnvelope`.

**`429`** — Rate limit exceeded. The body's `error.code` is `RATE_LIMITED` and `error.details.retry_after` is the same number of seconds as the `Retry-After` header. Returns `ApiErrorEnvelope`.
