# Toggle Access Point

## Operate Access Point

<mark style="color:green;">`POST`</mark> `https://api.parqex.com/oauth/v1/endpoint/toggle`

Open or close a single access point for a user.

#### Headers

| Name            | Type   | Description                      |
| --------------- | ------ | -------------------------------- |
| Accept          | string | Always set to `application/json` |
| Content-Type    | string | Always set to `application/json` |
| Authorization   | string | Set to `Bearer <ACCESS_TOKEN>`   |
| Accept-Charset  | string | Always set to `utf-8`            |
| Accept-Encoding | string | Always set to `gzip`             |

#### Request Body

| Name        | Type   | Description                                                              |
| ----------- | ------ | ------------------------------------------------------------------------ |
| door\_state | string | Requested state of the access point, either "OPEN" or "CLOSED"           |
| door\_id    | string | UUID of the access point (ex: door, garage etc.) to operate (open/close) |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "timestamp": 123123123123,
    "message":, "200"
}
```

{% endtab %}

{% tab title="400 " %}

```
{
    "success": true,
    "timestamp": 123123123123,
    "message":, "Error communicating with $hardware_name. Malformed Request. (400)"
}
```

{% endtab %}

{% tab title="401 " %}

```
{
    "success": true,
    "timestamp": 123123123123,
    "message":, "Error communicating with $hardware_name. Authentication error. (401)"
}
```

{% endtab %}

{% tab title="404 " %}

```
{
    "success": true,
    "timestamp": 123123123123,
    "message":, "Sorry, your $hardware_name can't be found. Please unplug the $hardware_name and then plug it back in."
}
```

{% endtab %}

{% tab title="428 " %}

```
{
    "success": true,
    "timestamp": 123123123123,
    "message":, "Your $hardware_name requires pairing a door sensor before the request can be processed. (428)"
}
```

{% endtab %}

{% tab title="501 " %}

```
{
    "success": true,
    "timestamp": 123123123123,
    "message":, "Error communicating with $hardware_name. Not Implemented error. (501)"
}
```

{% endtab %}
{% endtabs %}

The **/toggle** endpoint is used to open or close the specified garage door. In the request, you must specify the UUID of the door plus the requested state (ie. "OPEN" or "CLOSED"). The Controller ultimately decides how to process the TOGGLE request depending on the current known state of the specified door.

An example request may look like this:

```bash
POST /api/oauth/v1/endpoints/toggle HTTP/1.1
Host: https://parqex.com
Content-Type: application/json
Accept: application/json
Authorization: Bearer <ACCESS_TOKEN>
Accept-Charset: utf-8
Accept-Encoding: gzip

{ "door_id": "cbd3nb34877293484bcccbbd29393", "door_state": "OPEN" }
```

The body of the request must be valid JSON and both of the fields are required. The`door_id` field comes from the data of the [/sync](/-MUyxAVrX9S4wky8UoX6/api-endpoints/get-user-devices.md) endpoint. The `door_state` field should be thought of as a requested state of the door. It has two valid values: OPEN (to request the door to open) and CLOSED (to request the door to close).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.parqex.com/-MUyxAVrX9S4wky8UoX6/api-endpoints/toggle-access-point.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
