# Operate a product

`POST https://api.parklio.com/v2/products/{id}/state`

Sends an operation to a product through a Gateway. **Asynchronous:** the response is an `event_id`, and the result arrives later over [realtime](/realtime/connecting): a `lot_change` with the same `event_id` on success, or a `gateway_error` on failure. Connect to realtime **before** you call this.

| Operation | Barrier | Gate, chain, bollard, brain |
| --- | --- | --- |
| `open` | arm lowers | passage opens |
| `close` | arm rises | passage closes |
| `force_close` | ✅ | — |
| `stay_open`, `stay_close`, `clear_stay_open`, `clear_stay_close` | — | ✅ |

The API doesn't check the combination: check it yourself. Needs the `REMOTE_CONTROL` feature.

Errors before anything is sent: `214` (an operation on this product is still running), `704` (no Gateway sees the product), `206` (not paired), `30` (no remote control in the subscription).

See [Asynchronous operations](/concepts/asynchronous-operations) and the [Remote control](/guides/remote-control) guide.

**Auth:** `Authorization: Bearer <token>`

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | The product's `id`. |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `operation` | string (`open`, `force_close`, `close`, `stay_open`, `stay_close`, `clear_stay_open`, `clear_stay_close`) | yes | The operation that we want to run on a product. |
| `wait_for_completion` | boolean | no | Used to disable operation retry. In normal circumstances the API is going to wait until a operation succedes in changing the state,for example when sending a "close" command, the API will wait until the product is in a closed state. If that times out it will retry multiple times. In situations when using a brain, this can couse problems if the brain is not setup with input sensors since there will be no open/close state to read. |

```json
{
  "operation": "open",
  "wait_for_completion": true
}
```

## Responses

### 200

```json
{
  "success": true,
  "data": {
    "event_id": "a1b2c3d4"
  }
}
```

### 401 — Account user is not logged in and they should log in again.

```json
{
  "success": false,
  "errors": [
    {
      "code": 1,
      "message": "Unauthorized access."
    }
  ]
}
```

### 403 — User does not have permission to access requested resource.

```json
{
  "success": false,
  "errors": [
    {
      "code": 4,
      "message": "No permission."
    }
  ]
}
```

### 404 — Resource that has been requested does not exist. User should not try to repeat this request.

```json
{
  "success": false,
  "errors": [
    {
      "code": 6,
      "message": "Resource not found."
    }
  ]
}
```

