> ## Documentation Index
> Fetch the complete documentation index at: https://docs.membrane.agency/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API Mapping

The REST API Mapping function type maps functions to REST API endpoints.

It is defined like this:

```yaml theme={null}
type: rest-api-mapping
mapping:
  path: /contacts
  method: GET
  requestMapping:
    query:
      limit: 100
      offset:
        $var: $.cursor
  responseMapping:
    records:
      $var: response.data.contacts
```

## Format

* `path` – The API endpoint path
* `method` – HTTP method (GET, POST, PUT, PATCH, DELETE)
* `requestMapping` – Request mapping
  * `query` – Query parameters mapping
  * `headers` – Headers mapping
  * `data` – Request body mapping for POST/PUT/PATCH
  * `pathParameters` – Values for placeholders in the path (e.g., `{projectId}`)
* `responseMapping` – Mapping to transform the API response

## Variables

* `credentials` – Authentication credentials from the current connection
* `parameters` – Function-level and collection-level parameters combined
* Function-specific input variables

For `responseMapping`:

* `response.data` – API response data
* `response.headers` – API response headers
* `response.statusCode` – API response status code

## Using in Connector Files

When used in connector files, the mapping is written in a separate file named `<function-name>.rest.yml` (or `<function-name>.api.yml`).

For example:

```yaml theme={null}
# Function that lists contacts from an external API.
# File location: data/contacts/list.rest.yml
path: /contacts
method: GET
requestMapping:
  query:
    limit: 100
    offset:
      $var: $.cursor
responseMapping:
  records:
    $var: response.data.contacts
  cursor:
    $var: response.data.nextOffset
```
