# Handshake

## Handshake - Get your MTLS CERT\&KEY

<mark style="color:green;">`POST`</mark> `/handshake`

To access and utilize the full functionality of our API, you must obtain an MTLS (Mutual TLS) Certificate and key for secure authentication.

**Important:** All API functions, except for **Handshake** and **Subscription**, mandate MTLS authentication. Without this authentication, access to these functions will be restricted.

Ensure your MTLS credentials are properly configured before proceeding with the API integration.

**Headers**

| Name         | Value              |
| ------------ | ------------------ |
| Content-Type | `application/json` |

**Body**

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| `apikey` | string | apikey      |

**Response**

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

```json

{
    "mtls_cert": <MTLS_CERT>,
    "mtls_key": <MTLS_KEY>,
    "status": "success",
    "message": "Handshake executed successfully, to execute API functions use the MTLS CERT and KEY attached to your apikey.",
    "timestamp": "2025-01-21 16:00:00"
},
```

{% endtab %}

{% tab title="400" %}

```json
{
    "status": "Failed",
    "message": "No data received or invalid JSON",
    "timestamp": "2025-01-21 16:00:00"
},

```

{% endtab %}

{% tab title="401" %}

```json
{
    "status": "Failed",
    "message": "API key is required",
    "timestamp": "2025-01-21 16:00:00"
}
```

{% endtab %}

{% tab title="402" %}

```json
{
    "status": "Failed",
    "message": "Invalid API key",
    "timestamp": "2025-01-21 16:00:00"
}
```

{% endtab %}

{% tab title="403" %}

```json
{
    "status": "Failed",
    "message": "Internal server error: Could not load MTLS data",
    "timestamp": "2025-01-21 16:00:00"
}
```

{% endtab %}

{% tab title="405" %}

```json
{
    "status": "Failed",
    "message": "No MTLS data available",
    "timestamp": "2025-01-21 16:00:00"
}
```

{% endtab %}

{% tab title="500" %}

```json
{
    "status": "Failed",
    "message": "Internal server error: <Exception>",
    "timestamp": "2025-01-21 16:00:00"
}
```

{% endtab %}
{% endtabs %}

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

```javascript
const fetch = require('node-fetch');

const url = "https://your-api-url.com/handshake";
const headers = { "Content-Type": "application/json" };
const payload = { apikey: "your_api_key" };

fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error("Error:", error));

```

{% endtab %}

{% tab title="Python" %}

```python
import requests

url = "https://your-api-url.com/handshake"
headers = {"Content-Type": "application/json"}
payload = {"apikey": "your_api_key"}

response = requests.post(url, headers=headers, json=payload)
print(response.json())

```

{% endtab %}

{% tab title="Typescript" %}

```typescript
import fetch from 'node-fetch';

const url = "https://your-api-url.com/handshake";
const headers = { "Content-Type": "application/json" };
const payload = { apikey: "your_api_key" };

fetch(url, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(payload)
})
    .then((response) => response.json())
    .then((data) => console.log(data))
    .catch((error) => console.error("Error:", error));

```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
)

func main() {
	url := "https://your-api-url.com/handshake"

	payload := map[string]string{
		"apikey": "your_api_key",
	}

	payloadBytes, _ := json.Marshal(payload)
	req, _ := http.NewRequest("POST", url, bytes.NewBuffer(payloadBytes))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer resp.Body.Close()

	var result map[string]interface{}
	json.NewDecoder(resp.Body).Decode(&result)
	fmt.Println(result)
}

```

{% endtab %}

{% tab title="Rust" %}

```rust
use reqwest::Client;
use serde_json::json;
use tokio;

#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
    let url = "https://your-api-url.com/handshake";
    let client = Client::new();

    let payload = json!({
        "apikey": "your_api_key"
    });

    let response = client
        .post(url)
        .json(&payload)
        .send()
        .await?;

    let response_text = response.text().await?;
    println!("{}", response_text);

    Ok(())
}

```

{% endtab %}
{% endtabs %}


---

# 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.0xleverage.io/overview/leverage-api/handshake.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.
