# Authorization

## Authorization key

To start using our API, you need an API Key. You can get the API Key from Coresignal's [self-service platform](https://dashboard.coresignal.com/sign-in). Moreover, your account manager or sales representative can generate the key for you upon your request for the API plan.

***

## Authorization header

All requests must contain an `API Key` header. Its value is your unique API Key.

{% code title="Authorization header" %}

```json
-H “apikey: {API Key}”
```

{% endcode %}

## cURL authorization

Several examples of authorization in cURL are given according to the required request. Here, requests are made using Base Company API endpoints.

{% code title="Elasticsearch DSL" %}

```json
curl -X 'POST' \
'https://api.coresignal.com/cdapi/v2/company_base/search/es_dsl' \
  -H 'accept: application/json' \
  -H 'apikey: {API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
   //insert your query
}'
```

{% endcode %}

## General authorization templates

Templates for authentication in various programming languages and programming environment.

{% tabs %}
{% tab title="Python" %}

```python
import requests

api_endpoint = "API_ENDPOINT"
api_key = {API Key}

headers = {
    "apikey": api_key
}

response = requests.get(api_endpoint, headers=headers)

# Print the response content or handle it as needed
print(response.text)
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'net/http'
require 'uri'

uri = URI.parse("API_ENDPOINT")
http = Net::HTTP.new(uri.host, uri.port)

request = Net::HTTP::Get.new(uri.request_uri)
api_key = {API Key}
request['apikey'] = api_key

response = http.request(request)
puts response.body
```

{% endtab %}

{% tab title="Node.js" %}

```nodejs
const https = require('https');

const apiEndpoint = 'API_ENDPOINT';
const apiKey = {API Key};

const options = {
    headers: {
        'apikey': apiKey
    }
};

https.get(apiEndpoint, options, (response) => {
    let data = '';
    response.on('data', (chunk) => {
        data += chunk;
    });

    response.on('end', () => {
        console.log(data);
    });
});
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$apiEndpoint = "API_ENDPOINT";
$apiKey = {API Key};

$options = [
    'http' => [
        'header' => "apikey: $apiKey"
    ]
];

$context = stream_context_create($options);
$response = file_get_contents($apiEndpoint, false, $context);
?>
```

{% endtab %}
{% endtabs %}

Use any API-compatible tool to authorize and start querying the API.

## FAQ

<details>

<summary>Where can I find my API Key?</summary>

API Key is stored in the [self-service platform](https://dashboard.coresignal.com/sign-in) home page's `API Keys` section.

</details>

<details>

<summary>How do I use API Key?</summary>

1. Change your authorization request header's to API Key: `-H 'apikey: {API Key}'`\
   Here, insert your API Key instead of `{API Key}`
2. Make sure that you are using the correct endpoints. For example: `/v2/company_base/search/es_dsl`

</details>
