---
type: api
title: Capture diagnostics for an Elasticsearch or Kibana resource
description: Retrieves a diagnostic bundle from an active cluster. To successfully retrieve a diagnostic bundle, the cluster must be responsive.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/cloud-enterprise/operation/operation-capture-deployment-resource-diagnostics
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/cloud-enterprise/operation/operation-capture-deployment-resource-diagnostics
products:
  - Elastic Cloud Enterprise
---

# Capture diagnostics for an Elasticsearch or Kibana resource

## Paths

- `POST` `/deployments/{deployment_id}/{resource_kind}/{ref_id}/diagnostics/_capture`

#### Path parameters

- `deployment_id` (string) — required
  Identifier for the Deployment
- `resource_kind` (string) — required
  The kind of resource (one of elasticsearch or kibana).
- `ref_id` (string) — required
  User-specified RefId for the Resource (or '_main' if there is only one).

## Description

Retrieves a diagnostic bundle from an active cluster. To successfully retrieve a diagnostic bundle, the cluster must be responsive.

## Authentication

- Basic: `Authorization: Basic <credentials>`
- Api key: `Authorization: <value>`

## Query string parameters

- `mode` (enum · default: full) — optional
  Capture mode - whether to obtain all the diagnostics data or the lightweight, essential-only subset of it. Applicable only to Elasticsearch, ignored for any other components which have just one capture mode implemented.
  Values: `full`, `light`

## Responses

#### `200`

The diagnostic bundle as a zip file

`application/json`

Type: `string · format: byte`

#### `404`

* The Deployment specified by {deployment_id} cannot be found. (code: `deployments.deployment_not_found`)
* The Resource specified by {ref_id} cannot be found. (code: `deployments.deployment_resource_not_found`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

#### `412`

The diagnostics cannot be generated because the cluster is either stopped or initializing. (code: `clusters.cluster_plan_state_error`)

`application/json`

- `errors` (object[])
  A list of errors that occurred in the failing request
  - `code` (string)
    A structured code representing the error type that occurred
  - `message` (string)
    A human readable message describing the error that occurred
  - `fields` (string[])
    If the error can be tied to a specific field or fields in the user request, this lists those fields
##### Response headers

- `x-cloud-error-codes` (enum)
  The error codes associated with the response

## Code examples

#### curl

```curl
curl -X POST "${API_URL}/deployments/${DEPLOYMENT_ID}/${RESOURCE_KIND}/${REF_ID}/diagnostics/_capture" \
  -u "${USERNAME}:${PASSWORD}"
```

