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

# Call an environment

> Send provider-shaped requests with the session-scoped credentials returned at readiness.

The session response returns an `apiBaseUrl` for every selected environment.
Append the provider’s normal path to that URL and apply the exact header map in
the same connection's `credentials.headers` field.

```js theme={null}
const github = session.environments.github;
const response = await fetch(`${github.apiBaseUrl}/user`, {
  headers: github.credentials.headers,
  signal: AbortSignal.timeout(15_000),
});
```

Stable data-plane URLs have this form:

```text theme={null}
https://api.archal.ai/v1/sessions/{sessionId}/environments/{environmentId}/api/{providerPath}
```

The gateway supports `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `HEAD`.
Query strings, request bodies, provider content types, and safe response headers
pass through without changing the provider-shaped contract.

## Keep credentials separate

The workspace key authorizes lifecycle calls only. Provider-shaped calls reject
that key and any real provider token. Archal validates the returned
session-scoped credential, removes caller-supplied provider credential headers,
and injects a separate private worker credential.

## Example mutation

```js theme={null}
const response = await fetch(`${github.apiBaseUrl}/user/repos`, {
  method: 'POST',
  headers: {
    ...github.credentials.headers,
    'content-type': 'application/json',
  },
  body: JSON.stringify({ name: 'checkout-eval', private: true }),
  signal: AbortSignal.timeout(15_000),
});
```

Provider errors are returned with their HTTP status and response body. Gateway
errors include an Archal request ID when available.
