# Call the integration's API (POST)

> Source: https://truto.one/docs/api-reference/admin/custom-api/post/

`POST /custom/{path}`

Resource: **Custom API**

Sends a `POST` to the integration's API with the request body. Works the same way for `PUT`, `PATCH` and `DELETE`.

A JSON body can carry `methodConfig`, a resource method config (the shape of one in the integration config) that Truto applies to this call, for example `methodConfig.path`; it is removed before the body is sent. `methodConfig.base_url` is refused with a `400`: Custom API calls always use the integration's base URL.

**Auth:** an API token, or an integrated account token.

## Path parameters

- **`path`** _(string, required)_
  The path to call on the integration's API, after its base URL. It can span several segments (`/custom/v1/users/42`). It must stay on the integration's host: an absolute or protocol-relative path is a `400`.

## Query parameters

- **`integrated_account_id`** _(string)_
  The integrated account to call. Required unless you call with an integrated account token.
- **`truto_response_format`** _(string)_
  `stream` returns the integration's response body as it arrives, without parsing it. Files and other non-JSON responses are already streamed; use `stream` for JSON or XML responses too large to process. `raw` returns the integration's whole response body instead of only the records at the method's response path.
  Allowed: `raw`, `stream`

## Request body

- **`methodConfig`** _(object)_
  An integration method config applied to this call. Removed from the body before it is sent.

## Response body

- **`result`** _(array<unknown> | object)_
  The integration's response body, as the integration returned it.
- **`next_cursor`** _(string)_
  The integration's `next_cursor`, when its response body carries one.
- **`prev_cursor`** _(string)_
  The integration's `prev_cursor`, when its response body carries one.

## Code examples

### curl

```bash
curl -X POST 'https://api.truto.one/custom/{path}?integrated_account_id=<integrated_account_id>' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "methodConfig": {}
}'
```

### JavaScript

```javascript
const integratedAccountId = '<integrated_account_id>';

const body = {
  "methodConfig": {}
};

const response = await fetch(`https://api.truto.one/custom/{path}?integrated_account_id=${integratedAccountId}`, {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/custom/{path}"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
    "integrated_account_id": "<integrated_account_id>"
}
payload = {
    "methodConfig": {}
}

response = requests.post(url, headers=headers, params=params, json=payload)
print(response.json())
```
