> For the complete documentation index, see [llms.txt](https://docs.coresignal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coresignal.com/guides/turning-a-natural-language-query-into-an-api-integration.md).

# Turning a Natural Language Query Into an API Integration

Turn natural-language prompts into validated Elasticsearch DSL queries for Coresignal API integrations.

Coresignal's playground is ideal for initial tests and pulling small-scale data, but relying on manual queries can quickly slow your workflow. As demand grows, API integration allows you to automate and scale your workflows.

This guide shows you how to use [API Playground](/self-service/features-and-tools/api-playground.md) to generate and carry a tested query into the appropriate API endpoint. You will learn how to get an Elasticsearch DSL query with a natural language prompt that you can edit to match your search criteria and reuse in production whenever needed.

Keep reading for a step-by-step overview of the workflow using API Playground, common errors you may run into, and how to solve them.

### From prompt to query

The API Playground provides a visual interface within the dashboard for interactively designing queries across Employee, Company, or Job datasets. With one request, the API Playground returns multiple matching IDs, letting you evaluate the prompt's accuracy and whether it needs refining.

{% stepper %}
{% step %}
**Open API Playground**

Navigate to the Coresignal's dashboard and on the side menu under Explore our APIs click API Playground to open it.

<figure><img src="https://1856228217-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEGm9dJ1kZAi8Fay0jxwJ%2Fuploads%2FqxZ5VWtgLT6TwjSTYXPr%2FScreenshot%202026-10-21%20at%2014.19.37.png?alt=media&amp;token=2a96b7a3-e41e-4098-8873-1d4a40f35215" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Write a prompt**

Start with a natural-language prompt in the API Playground. For example, type:

{% prompt description="Find individuals in Atlanta with both UX and UI skills." %}

```markdown
Find individuals in Spain with both UX and UI skills.
```

{% endprompt %}

Right after submitting your prompt, you will receive:

* The generated Elasticsearch DSL request structure (which you can copy directly into your API integration code) readily available in the Search request field

<figure><img src="https://1856228217-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEGm9dJ1kZAi8Fay0jxwJ%2Fuploads%2FtPNWmhdXXShtoMmR7fSS%2FES%20DSL%20query.png?alt=media&amp;token=2622f699-2845-4ea1-8938-abf86b83ff3a" alt=""><figcaption></figcaption></figure>

{% code title="Generated query sample" expandable="true" %}

```json
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "is_deleted": 0
          }
        },
        {
          "term": {
            "is_parent": 1
          }
        }
      ],
      "must": [
        {
          "bool": {
            "must": [
              {
                "bool": {
                  "should": [
                    {
                      "match": {
                        "summary": {
                          "query": "UX",
                          "operator": "and"
                        }
                      }
                    },
                    {
                      "match": {
                        "headline": {
                          "query": "UX",
                          "operator": "and"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              },
              {
                "bool": {
                  "should": [
                    {
                      "match": {
                        "summary": {
                          "query": "UI",
                          "operator": "and"
                        }
                      }
                    },
                    {
                      "match": {
                        "headline": {
                          "query": "UI",
                          "operator": "and"
                        }
                      }
                    }
                  ],
                  "minimum_should_match": 1
                }
              }
            ]
          }
        },
        {
          "match_phrase": {
            "location_city": "Atlanta"
          }
        }
      ]
    }
  },
  "sort": [
    "_score"
  ]
}
```

{% endcode %}

* All matching record IDs
* One full sample record preview
  {% endstep %}

{% step %}
**Move to production**

Copy the generated DSL request directly into your integration. The Playground provides pre-formatted snippets in cURL, Python, and Node.js.

<img src="https://1856228217-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEGm9dJ1kZAi8Fay0jxwJ%2Fuploads%2FNFPhGIAc0Eyb2k36sOrV%2Funknown.png?alt=media&amp;token=6d34ad94-a3d7-48b1-8903-48d2c84b70c6" alt="" height="445" width="624">

To retrieve full profile data for matching records:

* **Collect (for single record):** enter a valid `employee_id` value and your API Key into the request

{% code title="Collect request example" expandable="true" %}

```json
curl -X 'GET' \
BASE=https://api.coresignal.com/cdapi/v2/employee_multi_source
curl "$BASE/collect/123456780" \
  -H "{API Key}"
```

{% endcode %}

* **Bulk Collect:** supply the list of IDs directly to the Bulk Collect endpoint to fetch full profiles in a single request.
  {% endstep %}
  {% endstepper %}

### Authentication: dashboard to terminal

All requests described in this guide, across Search, Collect, Bulk Collect, and Agentic Search, require an API key passed via the [API Key](/self-service/account-management/authentication-and-api-keys.md) request header. You can get your API Key from Coresignal’s [self-service platform](https://dashboard.coresignal.com/home).

{% code title="Authorization header" expandable="true" %}

```json
-H “apikey: {API_Key}”
```

{% endcode %}

### Hardening for production

To ensure automated integrations run reliably at scale, there are several steps you can incorporate to ensure smooth production.

#### Two-step retrieval flow

Implement two-step retrieval flow to efficiently fetch data at scale:

1. Run Search request using your validated Elasticsearch DSL to retrieve matching entity IDs
2. Pass those IDs into Collect (for individual records) or Bulk Collect (for batches) to pull complete entity objects

#### Design around limits

To avoid additional roadblocks keep in mind limits and restrictions:<br>

* Bulk Collect endpoints accept up to 10,000 IDs per request. For result sets exceeding 10,000 IDs, split the array into multiple batch requests.
* [Credits](/api-introduction/credits.md) are deducted per delivered record and per Agentic Search query. Monitor the `x-credits-remaining` response header across both manual testing and production scripts to avoid pipeline interruptions.

#### Error handling

When testing or running queries, you may encounter the following scenarios and errors:

* No results (post response field displays `0`) – means the request succeeded but matched no records. To fix this issue, broaden search criteria, check for typos, and verify that the entity exists.
* Failed requests – this error means the system cannot process your query. To fix this, remove requests for private data and ensure your prompt is clear and descriptive. You can also check our page for a list of common [response codes](/api-introduction/response-codes.md) to help identify the problem.

### Related reading

| Resource                                                         | Text Description                                                           |
| ---------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [Semantic Search](/api-introduction/requests/semantic-search.md) | Expand Elasticsearch DSL queries to include titles with equivalent meaning |
| [Bulk Collect](/api-introduction/requests/bulk-collect.md)       | A guide on retrieving large sets of data in a single request               |
| [Collect](/guides/collect-enrich-or-bulk-collect.md)             | A detailed guide on Collect Endpoint and data collection                   |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coresignal.com/guides/turning-a-natural-language-query-into-an-api-integration.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
