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

# Create an asynchronous request

# Overview

Create and enqueue an asynchronous request.

Asynchronous requests will be queued. If the service is available at the moment, it will
soon be processed. Otherwise, if the service is currently scaled down to zero, the request
will get processed after the service becomes available.

The result can be queried in [output-fetching API](get-async-request-output).

## Interaction code example

<CodeGroup>
  ```shell curl theme={null}
  $ echo '
  {
      "method": "POST",
      "path": "/predictions/my-model",
      "data": {
          "question": "How are you?"
      }
  }' | curl \
      -H "Authorization: Bearer ${TOKEN}" \
      "${BASE_URL}/async" \
      --json @-

  {"id": "98nlux8b0eu6"}
  ```

  ```python Python theme={null}
  import requests
  base_url = "https://..."
  token = "..."

  r = requests.post(
      f"{base_url}/async",
      headers={"Authorization": f"Bearer {token}"},
      json={
          "data": {"question": "How are you?"}
          "method": "POST",
          "path": "/predictions/my-model",
      }
  )
  request_id = r.json()["id"]
  print(request_id) # prints: 98nlux8b0eu6
  ```
</CodeGroup>

# Request

<Info>
  <h3>Authorization</h3>

  You must provide a token in `Authorization` header with `Bearer` scheme, as:

  ```
  Authorization: Bearer <token>
  ```

  The token can be found in the web UI (in service overview's Request dialog).
</Info>

## Path parameters

<ParamField path="base_url" type="string" required>
  Base URL for your service. This value can be found in the web UI (in service overview's
  Request dialog).

  Typical value: `https://serve-api.dev2.vssl.ai/api/v1/services/<slug>`
</ParamField>

## JSON body parameters

<ParamField body="data" type="any" required>
  JSON data to send as body in the request to your service.
</ParamField>

<ParamField body="method" type="any" default="POST">
  Method to use in request. If unspecified, `POST` will be used.
</ParamField>

<ParamField body="path" type="any" default="/">
  Path to use in request. If unspecified, `/` (root path) will be used.
</ParamField>

# Response

<Note>
  On successful operation, this API will respond with HTTP status code 201 (Created).
</Note>

<ResponseField name="id" type="string">
  ID of the newly created request. It can be used to fetch its status and output.

  This is a lowercase-alphanumeric string with length 1 to 16.

  Example: `98nlux8b0eu6`
</ResponseField>

<RequestExample>
  ```json Request body theme={null}
  {
      "method": "POST",
      "path": "/predictions/my-model",
      "data": {
          "question": "How are you?"
      }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Response body (201 Created) theme={null}
  {
      "id": "98nlux8b0eu6"
  }
  ```
</ResponseExample>
