# Register

## POST /v1/internal/auth/register

Registers a new user on the platform using wallet signature verification.\
This endpoint is intended for partner services integrating via our internal API.\
The registered user is automatically linked as a referral to the API key owner.

#### Authorization

* Requires a valid API key passed in the `x-api-key` header.
* Signature verification is used to confirm wallet ownership.

### Request

**Headers:**

```
x-api-key: your-api-key-here
Content-Type: application/json
```

**Body:**

```json
{
  "publicKey": "Base58-encoded wallet address",
  "signature": "Signature of the message returned from get-message",
  "nonce": "Nonce previously received"
}
```

#### Flow

1. Call `GET /v1/internal/auth/get-message` to obtain a message and nonce.
2. Ask the user to sign the message with their wallet.
3. Send the `publicKey`, `signature`, and `nonce` to this endpoint.
4. If successful, the user is registered and linked to the owner of the API key.

### Response

```json
{
  "status": 200,
  "success": true
}
```

#### Errors

| Status | Message                              | Description                               |
| ------ | ------------------------------------ | ----------------------------------------- |
| 401    | Missing API key                      | The `x-api-key` header is required        |
| 403    | Nonce used or expired                | The provided nonce is invalid or expired  |
| 403    | Invalid signature                    | The wallet signature is not valid         |
| 403    | User already registered              | This wallet is already registered         |
| 404    | Cant find user with this invite code | The inviter (API key owner) was not found |

***

## GET /v1/internal/auth/get-message

Generates a  message and nonce for the wallet to sign. \
This is the first step in the signature-based registration flow.

#### Authorization

* Requires a valid API key passed in the `x-api-key` header.

### Request

**Headers:**

```
x-api-key: your-api-key-here
```

### Response

```json
{
  "message": "Authentication request from Something.cool.  Nonce: ..........",
  "nonce": "............."
}
```

#### Notes

* The `message` returned must be signed by the user's wallet.
* The `nonce` is one-time use and will expire shortly after creation or after being used.


---

# 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.something.cool/internal-api/register.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.
