# Webhook Authentication

{% hint style="info" %}
*Auth webhooks are not available on the free tier.*
{% endhint %}

Once you’ve created a Web World, you can configure authentication providers to control access.

To enable auth webhooks, in the MSquared Dashboard, go to **Projects > \[Your Project] > Web World Instances > \[Your World]** and navigate to **Auth Configuration**.

<figure><img src="/files/frhY8HoSNnD7yf1R4reM" alt=""><figcaption></figcaption></figure>

Here you can enable or disable anonymous access. If using authentication, you’ll likely want to disable it - otherwise both anonymous and authenticated users can access your world.

To use webhook auth to connect to a world, pass a token as a query parameter in the URL. For example (replace `TOKEN`):

```
https://example-project-id_example-world-id.mml.world?token=TOKEN
```

During connection, the Webhook URL is called with the token as a query parameter—your backend must validate it. For example:

```
https://example.com/api/my-auth-endpoint?token=PASSED_THROUGH_TOKEN
```

If the webhook responds with anything other than a `200` status then the user's connection will be rejected.

The body of the response must also contain the user connection details matching one of the following schemas:

```typescript
{
    username: string,
    characterDescription:   
      | {
          meshFileUrl: string;
          mmlCharacterString?: null;
          mmlCharacterUrl?: null;
        }
      | {
          meshFileUrl?: null;
          mmlCharacterString: string;
          mmlCharacterUrl?: null;
        }
      | {
          meshFileUrl?: null;
          mmlCharacterString?: null;
          mmlCharacterUrl: string;
        };
}
```

The properties are:

* `username`  - the user's name to appear as in world.
* `characterDescription.meshFileUrl`  - a publicly accessible URL for downloading a mesh.
* `characterDescription.mmlCharacterString`  - a valid [\<m-character>](https://mml.io/docs/reference/elements/m-character).
* `characterDescription.mmlCharacterUrl`  - a publicly accessible url for downloading an mml character.

The quickest way to get started is using `characterDescription.mmlCharacterUrl` and setting it to the processed `mmlUrl` result of an MSquared Avatar upload.

{% hint style="success" %}
See how to produce a `mmlUrl`  in the Avatars [Getting Started](/dash/avatars/getting-started.md) guide.
{% 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.msquared.io/dash/web-worlds/webhook-authentication.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.
