# GraphQL entries query

_NgCms / Content Entries_

`POST /ng-cms/graphql`

## Parameters

- `x-api-key` (string, required) — API key header. Required on every request, same as the REST endpoints.
- `x-bucket-id` (string, required) — Project/bucket ID header. Unlike REST content-entries endpoints, this GraphQL endpoint has no {projectId} route segment, so the bucket is resolved exclusively from this header - it must always be sent.
- `projectId` (string, required) — GraphQL argument on the entries query. Selects which project's entries to query - independent of the x-bucket-id header (which drives auth/plan/rate-limit validation only), but normally set to the same value.
- `typeKey` (string, required) — Content type key or ID whose entries to list, e.g. "post".
- `status` (CmsEntryStatus, optional) — Filter by entry status: DRAFT, PUBLISHED, or ARCHIVED. Omit to return entries in any status.
- `search` (string, optional) — Free-text search across entry fields.
- `fieldFilters` ([FieldFilterInput!], optional) — List of exact-match field filters, e.g. [{ key: "slug", value: "my-post" }].
- `excludeIds` ([String!], optional) — Entry IDs to exclude from the results.
- `offset` (number, optional, default: `0`) — Pagination offset (0-based).
- `limit` (number, optional, default: `50`) — Max entries to return. Must be between 1 and 1000.
- `sortBy` (string, optional, default: `"created_at"`) — Sort field. Allowed: created_at, updated_at, published_at.
- `sortDir` (string, optional, default: `"desc"`) — Sort direction. Allowed: asc, desc.
- `lang` (string, optional) — Filter by entry language code.

## Request Body

### `GraphQL request body`

- `query` (string, required) — The GraphQL document to execute, e.g. "{ entries(projectId: \"...\", typeKey: \"post\") { total items { id } } }".
- `variables` (object, optional) — Optional variables object if the query uses GraphQL variables instead of inline literals.

### `FieldFilterInput`

- `key` (string, required) — Field key to filter on, e.g. "slug".
- `value` (string, required) — Exact value to match.

## Responses

### `200` — GraphQL responses always return HTTP 200, whether the query succeeded or failed at the GraphQL level (unknown typeKey, invalid limit/sortBy, etc.). Check the top-level errors array to distinguish success from failure - HTTP status codes below 200 only occur for authentication/access-control failures, which are rejected before the query runs.

Type: `GraphQLResponse`

- `data` (object) — Present when the query executed without errors. Contains an entries field shaped as CmsEntryConnection.
  - `entries` (CmsEntryConnection)
    - `total` (number) — Total number of matching entries (ignores offset/limit).
    - `items` (CmsEntry[]) — Page of entries.
      - `id` (string) — Entry ID.
      - `type` (string) — Content type key.
      - `status` (CmsEntryStatus) — DRAFT | PUBLISHED | ARCHIVED.
      - `fields` (Any) — Arbitrary JSON object of the entry's field values, same shape as the REST content-entries response. Typed as GraphQL's built-in Any scalar (functionally a JSON scalar), not a custom "JSON" type - reference and media fields are resolved into nested objects exactly as in the REST slim response.
      - `schemaVersion` (number) — Content type schema version the entry was created against.
      - `version` (number) — Entry version number.
      - `createdAt` (DateTime) — ISO-8601 creation timestamp.
      - `updatedAt` (DateTime) — ISO-8601 last-update timestamp.
      - `publishedAt` (DateTime) — ISO-8601 publish timestamp, null if never published.
      - `archivedAt` (DateTime) — ISO-8601 archive timestamp, null if not archived.
      - `lang` (string) — Entry language code, if set.
- `errors` (GraphQLError[]) — Present when the query failed. One entry per error.
  - `message` (string) — Human-readable error message, e.g. "Unknown typeKey 'x' for project 'y'.", "limit must be between 1 and 1000.", "Invalid sortBy value. Allowed: created_at, updated_at, published_at."

### `401` — Missing or invalid x-api-key header.


### `403` — Missing projectId/bucketId - neither a route value nor the x-bucket-id header was provided.


### `412` — Precondition Failed. Project's plan doesn't allow access to the requested resource.


### `429` — Rate limit exceeded for the bucket.



## Code Examples

### curl

```curl
curl --request POST \
  --url https://apis-spb.konso.io/ng-cms/graphql \
  --header 'x-api-key: <your-api-key>' \
  --header 'x-bucket-id: <your-project-id>' \
  --header 'Content-Type: application/json' \
  --data '{"query":"{ entries(projectId: \"<your-project-id>\", typeKey: \"post\", limit: 5) { total items { id fields } } }"}'
```

### javascript

```js
const query = `{ entries(projectId: "<your-project-id>", typeKey: "post", limit: 5) { total items { id fields } } }`;

fetch('https://apis-spb.konso.io/ng-cms/graphql', {
  method: 'POST',
  headers: {
    'x-api-key': '<your-api-key>',
    'x-bucket-id': '<your-project-id>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ query })
})
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```

### dotnet

```dotnet
var query = "{ entries(projectId: \"<your-project-id>\", typeKey: \"post\", limit: 5) { total items { id fields } } }";

var request = new HttpRequestMessage(HttpMethod.Post, "https://apis-spb.konso.io/ng-cms/graphql")
{
    Content = JsonContent.Create(new { query })
};
request.Headers.Add("x-api-key", "<your-api-key>");
request.Headers.Add("x-bucket-id", "<your-project-id>");

var response = await client.SendAsync(request);
```

### python

```python
query = '{ entries(projectId: "<your-project-id>", typeKey: "post", limit: 5) { total items { id fields } } }'

response = requests.post(
    'https://apis-spb.konso.io/ng-cms/graphql',
    json={'query': query},
    headers={'x-api-key': '<your-api-key>', 'x-bucket-id': '<your-project-id>'}
)
```

### Request Body Example

```json
{
  "x-api-key": "example-string",
  "x-bucket-id": "example-string",
  "projectId": "example-string",
  "typeKey": "example-string",
  "status": "example-value",
  "search": "example-string",
  "fieldFilters": "example-value",
  "excludeIds": "example-value",
  "offset": 0,
  "limit": 50,
  "sortBy": "created_at",
  "sortDir": "desc",
  "lang": "example-string"
}
```

### Response Example (200)

```json
{
  "data": {
    "entries": {
      "total": 1,
      "items": [
        {
          "id": "cnt_a1b2c3d4e5f6",
          "type": "post",
          "status": "PUBLISHED",
          "fields": {
            "title": "Hello World",
            "slug": "hello-world",
            "content": "<p>Content.</p>"
          },
          "createdAt": "2026-07-31T10:15:00Z"
        }
      ]
    }
  }
}
```
