# Authentification

#### 🔑 Getting an API Key <a href="#getting-an-api-key" id="getting-an-api-key"></a>

1. Sign up or log in to your sandbox account at: <https://app.coopfinnetwork.com/login>
2. Navigate to **Settings > Developer Setting**
3. Complete your developer profile

**🎉 Make your first request**

### **Generate your first token**

## Generate your first token

<mark style="color:green;">`POST`</mark> <https://api.coopfinnetwork.com/v1/sandbox/token>

\<Description of the endpoint>

**Headers**

**Body**

| Name        | Type   | Description                         |
| ----------- | ------ | ----------------------------------- |
| api\_key    | string | The api key issued by the system    |
| secret\_key | string | The secret key issued by the system |

**Response**

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

```json
{
    "token_type": "Bearer",
    "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOi8vYXBpLmNvb3BmaW5uZXR3b3JrLmNvbSIsImlhdCI6MTc3ODU0MzQ1MiwiZXhwIjoxNzc4NjI5ODUyLCJ1c2VyX2lkIjoiOEdwNzdzU0wwdzBkS1hCOERpMDkycWVmcldxdmEzZnJFbXQ2aE1ieFYzNDE4cHplajV2YkY1STY0SllveW5oSHVrc1BRanR3aTN1NjFUTzI5bmxVNENBMnhSOWthZFpjMXpveWw1bWdnTmM3In0.K1ABcsWUaboGsR-XxyKvocWhktAcIWTVPCd2dsjn4E4",
    "expires_in": 86400
}
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

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

```javascript
const url = 'https://api.coopfinnetwork.com/v1/sandbox/token';

const data = {
  api_key: "pk_G85mdzusjlK...",
  secret_key: "sk_7d03871lQ5..."
};

fetch(url, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(data)
})
.then(response => response.json())
.then(result => console.log(result))
.catch(error => console.error('Error:', error));
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://api.coopfinnetwork.com/v1/sandbox/token"

data = {
    "api_key": "pk_G85mdzusjlK...",
    "secret_key": "sk_7d03871lQ5..."
}

headers = {
    "Content-Type": "application/json"
}

try:
    response = requests.post(url, json=data, headers=headers)

    # Affiche le status HTTP
    print("Status Code:", response.status_code)

    # Affiche la réponse JSON
    print(response.json())

except Exception as e:
    print("Error:", str(e))
```

{% endtab %}

{% tab title="PHP" %}

```ruby
<?php

$url = "https://api.coopfinnetwork.com/v1/sandbox/token";

$data = [
    "api_key" => "pk_G85mdzusjlK...",
    "secret_key" => "sk_7d03871lQ5..."
];

// Initialisation de cURL
$ch = curl_init($url);

// Configuration de la requête
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));

// Exécution de la requête
$response = curl_exec($ch);

// Vérification des erreurs
if(curl_errno($ch)) {
    echo 'Erreur cURL : ' . curl_error($ch);
} else {

    // Code HTTP
    $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    echo "Status Code : " . $httpCode . "<br><br>";

    // Réponse API
    echo $response;
}

// Fermeture de cURL
curl_close($ch);

?>
```

{% endtab %}

{% tab title="Untitled" %}

```csharp
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        string url = "https://api.coopfinnetwork.com/v1/sandbox/token";

        var json = @"{
            ""api_key"": ""pk_G85mdzusjlK..."",
            ""secret_key"": ""sk_7d03871lQ5...""
        }";

        using (HttpClient client = new HttpClient())
        {
            var content = new StringContent(json, Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage response = await client.PostAsync(url, content);

                string responseBody = await response.Content.ReadAsStringAsync();

                Console.WriteLine("Status Code: " + (int)response.StatusCode);
                Console.WriteLine("Response:");
                Console.WriteLine(responseBody);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }
        }
    }
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
The token is valid for 24 hours
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coopfinnetwork.com/authentification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
