# Put a resource in a service

`POST https://evohub.io/api/v1/catalog/resources/{id}/component`

Part of the [Catalog API](https://docs.evohub.io/catalog.md) reference · operationId `bindResource`.

Binds the resource to a service by hand (`{"component": "<id or
slug>"}`), or unbinds it (`{"component": null}`). The key is
required. A binding made here is never undone by a sweep. Unbinding a
resource whose `evohub.io/component` annotation names a service lasts
only until its next sweep: change the manifest to move it for good.

Requires the `catalog:resource:write` scope.

## Authorization

Any one of:

- `bearerKey`
- `headerKey`

Where:

- `bearerKey`: HTTP Bearer — An EvoHub API key (`evohub_…`) as a bearer token.
- `headerKey`: API key in the header `X-API-Key` — An EvoHub API key (`evohub_…`).

## Path parameters

- `id` (string, required, example `res_6b8d0f2a4c6e8a1c3e5b7d9f1a3c5e7b`): The resource's ID.

## Request body (required)

Content type: `application/json`

Type: `BindRequest`

- `component` (string | null, required): A service's ID or slug, or null to unbind.

## Responses

### 200 — The resource.

Content type: `application/json`

Type: `object`

- `data` (Resource)
  - `id` (string, example `res_6b8d0f2a4c6e8a1c3e5b7d9f1a3c5e7b`)
  - `environment_id` (string)
  - `source_id` (string)
  - `external_id` (string, example `k8s://5f0c2a7e-…/apps/v1/Deployment/payments/payments-api`)
  - `provider` (string, example `k8s`)
  - `kind` (string, example `Deployment`)
  - `name` (string, example `payments-api`)
  - `namespace` (string, example `payments`)
  - `component_id` (string | null)
  - `component_bound_by` (string | null): What bound it to its service, when something did.
  - `status` (string, one of `live`, `missing`, `gone`, `stale`)
  - `missing_since` (string (date-time) | null)
  - `first_seen_at` (string (date-time))
  - `last_seen_at` (string (date-time))
  - `images` (array of string)

### 400 — The request is not valid: a field or filter value is wrong (`VALIDATION_ERROR`, with a sentence saying what), the body is not the expected JSON or carries an unknown field (`INVALID_BODY`), the cursor is not one this list gave (`INVALID_CURSOR`), a binding names a service that does not exist (`UNKNOWN_COMPONENT`), or a `PATCH` tries to change a slug (`SLUG_IMMUTABLE`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `not found`)
  - `request_id` (string)

### 401 — No API key was sent, or it is unknown, revoked or expired (`UNAUTHORIZED`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `not found`)
  - `request_id` (string)

### 403 — The key lacks a scope this endpoint needs (`FORBIDDEN`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `not found`)
  - `request_id` (string)

### 404 — Nothing with this ID (or slug) exists in the organization (`NOT_FOUND`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `not found`)
  - `request_id` (string)

### 429 — Too many requests (`RATE_LIMITED`). Wait for `Retry-After` seconds.

Headers:

- `Retry-After` (integer): Seconds to wait before retrying.

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `not found`)
  - `request_id` (string)

### 500 — Something went wrong on EvoHub's side (`INTERNAL_ERROR`). Retry later.

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required, example `NOT_FOUND`)
  - `message` (string, required, example `not found`)
  - `request_id` (string)

## Example request

```bash
curl -X POST 'https://evohub.io/api/v1/catalog/resources/res_6b8d0f2a4c6e8a1c3e5b7d9f1a3c5e7b/component' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <TOKEN>' \
  -d '{
  "component": "payments-api"
}'
```
