> For the complete documentation index, see [llms.txt](https://docs.xp-protocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xp-protocol.io/products/xp-protocol/integrations/rest-api/authentication.md).

# Authentication

### Intro

To connect to the **XP API**, you will need an **authentication key** provided by the XP team.

You can request one here -> <contact@xp-protocol.io>

### Valid score submission

1. You must be approved with a valid api key to submit scores to this endpoint.
2. For a score to take effect, you must also sign the update with a wallet address that is approved as an "owner" or "updater" for that specific XP Project Id. (Can be added in your dashboard/Directly on contract)

### Connecting

Connect using the "X-API-KEY" header in your request

```javascript
"X-API-KEY":"<api-key>"
```

### Example Request

```javascript
let myHeaders = new Headers();
let message = Date.now().toString();
let signatureObject = await web3.eth.accounts.sign(message, <PRIVATE_KEY>);
let signature = signatureObject.signature;

//Headers
myHeaders.append("X-API-KEY","<key>");
myHeaders.append("Content-Type", "application/json");
  
  //Send to API
    const body = JSON.stringify({
        "updateId": updateId,
        "projectId": <PROJECT_ID>,
        "actionName": <action-name>,
        "scoreType": <scoreType>,
        "targetWallet": <targetAddress>,
        "signature": signature,
        "message": message
    })
    const requestOptions = {
        method: 'POST',
        headers: myHeaders,
        body: body,
        redirect: 'follow'
    };
    
    let response = await fetch('https://api.xp-protocol.io/update-score, requestOptions).then(async (response) => ({ status: response.status, value: await response.text() }));

```


---

# 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 dynamically by asking a question.

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

```
GET https://docs.xp-protocol.io/products/xp-protocol/integrations/rest-api/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
