Skip to content

Config Format

Config files can be YAML (.yaml / .yml) or JSON (.json). You can also pass a plain JavaScript object directly to FraftClient.


Top-level fields

FieldTypeRequiredDescription
versionnumberNoSchema version. Currently must be 1 if provided.
baseUrlstringYesBase URL prepended to all request paths.
headersRecord<string, string>NoGlobal headers merged into every request.
authAuthConfigNoGlobal auth applied to every request.
requestsRecord<string, RequestDef>YesNamed request definitions.
yaml
version: 1
baseUrl: https://api.example.com
headers:
  Accept: application/json
  X-Client: my-app
auth:
  type: apiKey
  in: header
  name: x-api-key
  value: "${env.API_KEY}"
requests:
  users:
    path: /users

Request definition

Each key under requests maps to a RequestDef:

FieldTypeDefaultDescription
pathstringURL path appended to baseUrl. Supports :param segments (e.g. /users/:id).
methodHttpMethod"GET"HTTP method: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS.
headersRecord<string, string>Per-request headers, merged over global headers.
paramsRecord<string, unknown>Query string parameters.
bodyunknownRequest body (serialized to JSON).
transformTransformStep[]Ordered list of transform steps applied to the response.
axiosConfigAxiosRequestConfigAdvanced axios options (timeout, responseType, etc.).

Path parameters

Use :param segments in path to mark dynamic parts of the URL. Supply the values at call time via pathParams in RunOverrides:

yaml
requests:
  getUser:
    path: /users/:id
  getUserPost:
    path: /users/:userId/posts/:postId
js
await client.run('getUser', { pathParams: { id: 42 } });
// → GET /users/42

await client.run('getUserPost', { pathParams: { userId: 3, postId: 7 } });
// → GET /users/3/posts/7

If a :param segment is present in path but the corresponding key is not supplied in pathParams, fraft throws at call time.


POST with a body

yaml
requests:
  createUser:
    path: /users
    method: POST
    headers:
      Content-Type: application/json
    body:
      name: Alice
      role: admin

GET with query params

yaml
requests:
  search:
    path: /search
    params:
      q: typescript
      limit: 10

Advanced axios options

yaml
requests:
  slowEndpoint:
    path: /report
    axiosConfig:
      timeout: 30000
      responseType: blob

Auth

Currently only API key auth (type: apiKey) is built in. For Bearer tokens or OAuth, use a middleware step to inject headers manually.

FieldTypeDescription
type"apiKey"Auth strategy.
in"header" | "query"Where to inject the key.
namestringHeader name or query param key.
valuestringKey value. Supports ${env.VAR_NAME} interpolation.

Inject as a header:

yaml
auth:
  type: apiKey
  in: header
  name: Authorization
  value: "Bearer ${env.ACCESS_TOKEN}"

Inject as a query param:

yaml
auth:
  type: apiKey
  in: query
  name: api_key
  value: "${env.API_KEY}"

Auth defined at the top level applies to every request. Per-request auth is not currently supported — use middleware if you need per-request auth overrides.


Environment variable interpolation

Any string value can embed environment variables using ${env.VAR_NAME} syntax. See Environment Variables for details.

Released under the MIT License.