---
title: "Import custom query workers"
method: POST
path: "/_fabric/{fabric}/_api/restql/import"
tags: ["Query Workers"]
---

# Import custom query workers

`POST /_fabric/{fabric}/_api/restql/import`

## Request

- The document declares no server URL.
- Auth: one of:
  - API key in header `Authorization`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/macrometa/apis/macrometa-api-reference/docs/_fabric/:fabric/_api/restql/import/post.ts> (a function with typed inputs; its response is checked against the schema)

Import custom queries.

## Path parameters

- `fabric` string, string, required

## Request body

- UserQueriesImportCustomQueries
  - `queries` object[]: JSON documents embedded into a list.
    - `name` string, required: Name for the query.
    - `value` string, required: Value of the query.
    - `parameter` object: Query bind parameters as JSON Object.
    - `type` 'c8ql' | 'sql': Query language.
  - `details` boolean: If *true* extra information for errors will be returned in the result.

## Response `200`

Successfully imported queries.

If there are any errors, an additional header *X-C8-Error-Codes* is set, that contains a map of the error codes that occurred together with their multiplicities, as in: 1205:10,1210:17 which means that in 10 cases the error 1205 "illegal document handle" and in 17 cases the error 1210 "unique constraint violated" has happened. The response body has additional failed document details in *details* object.

- ExampleImportCustomQuery200
  - `error` boolean: Flag if there was an error (true) or not (false). It is always true in this response.
  - `code` integer: The response code.
  - `result` object
    - `created` integer: Number of queries which were successfully imported.
    - `errors` integer: Number of queries which were failed to get imported.
    - `details` object
      - `errors` ImportQueryErrorDetails[]: Array of failed queries along with the respective errors
        - `query` object: The failed query object
        - `errorNumber` integer: The error code
        - `errorMessage` string: The error message

## Other responses

- `400`: Failed because of missing or malformed user-query.
- `403`: Failed because you do not have access to the GeoFabric or you have reached the limit on *Max Stored Query Workers*. You need to upgrade to *Scale* plan.

---

[API](https://skmtc.dev/macrometa/apis/macrometa-api-reference.md) - [All operations](https://skmtc.dev/macrometa/apis/macrometa-api-reference/llms.txt) - [OpenAPI document](https://skmtc.dev/macrometa/apis/macrometa-api-reference/revisions/2006b6d7f31d?raw)
