Chat & voice API documentation
Astralink Nexus is a hosted REST and WebSocket API. Any platform that can make HTTPS requests can use it: Unity, Android, iOS, consoles and the web. The API is in early access, so details may still change.
Overview
Base URL: https://www.astralink.nexus/api/v1. Requests and responses are JSON. You create a project in your account's API tab and get two keys:
- Public key (
pk_...): safe to put in a game or web page. Sent in theX-Astralink-Keyheader. Browsers are limited to the website origins you allow. - Secret key (
sk_...): for your server only. Sent asAuthorization: Bearer sk_.... Shown once and stored only as a hash.
Your server uses the secret key to vouch for a user and gets back a short-lived user token. The user's device uses that token for everything else.
Public and private IDs
Every user has two identities, kept apart on purpose:
- Public ID: assigned by your game or app (random if you like). It is the only ID your game ever sees. A user can stay anonymous with just this.
- Private ID: the user's own Astralink account, with a username and password they log into manually. It works across every game and is never sent to your game. Responses only show a display name and a masked hint of the username.
Sign-up rules. A username is mandatory and is also the user's own email address, [email protected], which can receive mail from outside services. Age is a mandatory plain number (like 8). Sign-up has two steps: /account/register checks the details and emails a 6-character code, and /account/confirm creates the account once the code is entered. Adults give their own email. Anyone under 18 gives a parent's email, the code goes to the parent (the child asks them for it), and confirming also creates the parent's free website account with a parent dashboard and safety alerts. Adults can add a full date of birth to their profile later; for children, the parent enters it.
Accounts a parent made. A parent can also make the child's account from their dashboard, with a temporary email and password. The first time that child signs in, POST /account/login (and /account/signin) answers 403 setup_required with a setup_token instead of an account token. Send that token with the username and password the child chose to POST /account/setup, which returns the account token exactly like login does. The hosted sign-in window does all of this for you; only a client that calls the API itself needs to handle it. A temporary password that was not used in time answers 403 temp_password_expired.
When a user logs in, call POST /account/link to sync the account with the public ID they hold in your game. If the account is already linked to another ID in your game, that earlier ID wins, so the user keeps the same identity on any device.
Names: random, or yours
Every chat needs to know who each person is. You choose how, per project, in the project page under How users get a name in your chat:
1. Random names (the default)
Nothing to build. Someone who arrives with no identity is given a name made of User and eight random letters and digits, such as UserK7M2Q9XA. It is kept on their device, so they have the same name next time, and they can change it themselves under Settings, Your name (or with nx.rename("Raven")). A name they type is checked by your link, email and phone filter if you use it; the random one never is.
const nx = Astralink.init({ publicKey: "pk_...", guest: true }); // a random name, no server needed
When someone presses Login and signs in with their Astralink account, the name they were given is linked to that account, and from then on it is the same person on any device. Their account's name replaces the random one, and they can't rename themselves in your game any more: the account owns it.
2. Your own name provider
Your game or website decides who each person is, from your own database or logic, and tells Astralink. Choose My own server gives the names. Anonymous visitors are then refused. There are two calls, both with your secret key:
# when someone enters: sign them in with the name from your database, and hand the token to their chat
curl -X POST https://www.astralink.nexus/api/v1/tokens -H "Authorization: Bearer sk_YOUR_SECRET_KEY" -H "Content-Type: application/json" -d '{"external_id":"u-9001","display_name":"Captain Ada","avatar_url":"https://example.com/ada.png"}'
# at any time: create or rename a person without signing them in (leave a field out to keep it as it is)
curl -X PUT https://www.astralink.nexus/api/v1/users/u-9001 -H "Authorization: Bearer sk_YOUR_SECRET_KEY" -H "Content-Type: application/json" -d '{"display_name":"Admiral Ada"}'
curl https://www.astralink.nexus/api/v1/users/u-9001 -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
// in the browser: ask your own server for a token whenever the SDK needs one (it asks again when the old one runs out)
const nx = Astralink.init({ publicKey: "pk_...", getToken: () => fetch("/my-server/chat-token").then(r => r.json()).then(j => j.token) });
external_id is whatever id you already use for the person. Names don't have to be unique: that is yours to decide. The people you name can't rename themselves, and they can still log in with an Astralink account, which links your id for them to it.
Astralink's own website works the same way: someone signed in to it chats as their account, with no made-up name.
Quick start
1. From your server, vouch for a user and get a token:
curl -X POST https://www.astralink.nexus/api/v1/tokens \
-H "Authorization: Bearer sk_YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{"external_id":"player-42","display_name":"Dex"}'
2. On the user's device, join a channel (it is created on first use) and send a message:
curl -X POST https://www.astralink.nexus/api/v1/channels/join \
-H "Authorization: Bearer USER_TOKEN" -H "Content-Type: application/json" \
-d '{"key":"scene:forest"}'
curl -X POST https://www.astralink.nexus/api/v1/channels/scene:forest/messages \
-H "Authorization: Bearer USER_TOKEN" -H "Content-Type: application/json" \
-d '{"text":"hello"}'
Channel keys can be any string your world already uses: 1 to 120 characters of letters, digits and : _ . -.
JavaScript SDK
For websites and web games, one script gives you a ready-made chat with a taskbar (chat, inbox, voice, podcast, login and your own buttons), or a small client to build your own. It is a thin wrapper over the REST and WebSocket API, so other platforms use the same calls directly.
<div id="chat" style="height:420px"></div>
<script src="https://www.astralink.nexus/static/astralink/sdk/astralink.js"></script>
<script>
const nx = Astralink.init({ publicKey: "pk_...", guest: true }); // guest: no backend needed
Astralink.mount(document.getElementById("chat"), { client: nx, channel: "global" });
</script>
Your own server can vouch for logged-in users instead: pass userToken, or a getToken function that fetches a fresh token from your server when one expires.
Build your own interface with the client: nx.connect(), nx.join(key), nx.send(key, text), nx.history(key), and events with nx.on("message", fn) (also typing, presence, connection, identity, error). Messages are sent over REST and received live over a WebSocket, falling back to polling automatically.
Login from a native game (Unity and the like). A native game has no window to hand a password to, so it works like a TV app. POST /api/v1/account/link/start with the player's user token answers { code, url, expires_in, interval }. Open url in the player's own browser: the same Astralink sign-in page, ending in "go back to the game". Meanwhile the game asks GET /api/v1/account/link/status?code=... (with the same user token) every interval seconds. It answers { "state": "pending" } until the player has finished, then once { "state": "done", "status": "linked" | "already_linked" | "switched", "token", "expires_at", "user", "account" }: the new user token to use from then on (for switched the account already had an identity in your game and it wins, exactly as with nx.login()). A code lasts 10 minutes, works once, and only the identity that asked for it can collect the result; an old or unknown code answers link_expired. The Unity package does all of this behind its Settings screen.
User login. nx.login() opens an Astralink sign-in window on astralink.nexus. The user types their username and password there, so your page never sees them. When they finish, their private account is synced with the public ID your game gave them and you receive only a new user token plus a display name.
Chat style and custom buttons
On your project's page, Download starter files gives you the SDK, your public key already filled in, and a working example. The style is not stored in those files: Astralink.mount loads it live from your project, so changes you make in the style editor appear in your game the next time it loads, with no new download.
In your account's Chat style page you pick a preset look, change colors, choose what to show or hide, set the window size, and choose a layout: full (icon bar on the side) or compact (bar underneath). Each project saves its own style. Astralink.mount applies it for you; to build your own interface, read it with nx.style() or GET /api/v1/style using the public key.
You can also add up to 8 custom taskbar buttons. A button is either a link (opens a web page, optionally with your own image as the icon) or an action (runs code in your game, for example to open your in-game shop). Astralink never stores or runs code: an action is only a name, and your game decides what it does.
nx.onAction("open-shop", function (button) {
myGame.openShop(); // your own in-game UI
});
Links must start with https:// or http://; anything else is dropped when you save. Action names use lowercase letters, digits, - and _.
Taskbar and modules
The taskbar is the ready-made app Astralink draws in your game: chat, inbox, voice, podcast, login and settings. In your project's page (account, API), the Taskbar and modules section decides what your users can have:
- Show the taskbar: turn it off to use only the API and SDK with your own interface.
Astralink.mount()then draws nothing and fires ataskbarevent. - Modules: tick the ones to allow. A module you leave off is hidden from every user and cannot be turned back on by them. Voice also decides whether voice rooms work at all in the project.
- Chat commands: whether users may type commands such as
/voice off(see below).
Colors, layout and your own buttons stay in the style editor. The style the SDK loads (GET /api/v1/style) already has these settings applied, so there is nothing extra to code.
Chat commands and user choices
You decide what is allowed; inside that, each user decides what they want to see. They can do it in Settings (the Features list) or by typing a command in the chat. A message that starts with one slash is a command: it runs on the user's own device, is never sent to anyone, and the answer is a private line only they see.
/helplists the commands./featureslists the user's features and whether each is on./features resetputs everything back./voice off,/inbox off,/podcast offhide that module (and/voice offalso leaves the voice room);/rooms,/members,/header,/avatars,/times,/typingand/emojihide parts of the chat. Useonto bring one back.- Users can only hide what you allow, never show what you left out. Chat itself cannot be switched off this way. Choices are remembered in their browser.
- A message that starts with two slashes,
//, is sent as normal text with one slash removed.
// your game can add its own commands:
nx.addCommand("shop", { help: "open the shop", run: function (args, say) { openShop(); say("Shop opened."); } });
// and use the same choices in your own interface:
nx.featureEnabled("voice"); // the user's choice
nx.setFeature("emoji", false);
nx.on("features", function (f) { /* { voice: true, emoji: false, ... } */ });
nx.on("system", function (m) { /* m.text: a private line to show only this user */ });
Private rooms with a code
Users can make their own private rooms. In the taskbar's chat, the + next to Rooms opens a pop-up with two options: Join, where they type a room code, and Create new, where they give the room a name. A new room gets a random code in the form #0E0E-0E0E (eight random digits and letters A to F) to share with friends. Anyone who types a matching code joins, and stays in the room until they leave it: the Leave room button is at the bottom of the room's member list on the right. When the last person leaves, the room and its messages are deleted.
A room is a private group channel, so only its members can read or write in it, and your moderation tools work on it like any other channel. Codes are checked per game: a code made in one game never opens a room in another. Codes can't be guessed by trying them one after another (15 tries a minute per user), and a user can be in up to 20 rooms and make 10 new ones an hour.
In your project's page, Let users make private rooms turns the whole feature off for your game (the + disappears and the calls below answer rooms_off). To build your own screens, use the client:
const room = await nx.createRoom("Raid squad"); // { key: "room:0E0E-0E0E", name: "Raid squad", code: "#0E0E-0E0E", ... } and you are in it
const same = await nx.joinRoom("#0e0e-0e0e"); // any capitals, with or without the #, spaces allowed
await nx.leaveRoom(room.key); // the room closes when the last member leaves
Over plain HTTP, with a user token: POST /api/v1/rooms with {"name":"Raid squad"} (answers 201 with the room and its code), POST /api/v1/rooms/join with {"code":"#0E0E-0E0E"}, and POST /api/v1/rooms/leave with {"key":"room:0E0E-0E0E"}. A room you are in shows up in GET /api/v1/channels with its code. Errors: bad_code, no_such_room, room_full, too_many_rooms, name_required, rooms_off.
Rooms you make in advance
You can also make rooms yourself, for everyone. In the chat designer (UI builder), the Rooms everyone can join section lists up to twelve rooms by name; add, rename, reorder or take them off, then Save to project. Each one becomes a real public channel that every user sees at the top of the room list, in your order, before their own private rooms, and can join even when new public channels are closed. The first one is where the app opens. Voice rooms made in advance are listed the same way, apart from the chat rooms, in the Voice rooms section. Renaming keeps a room's messages; taking one off the list only hides it (its messages stay, and putting it back restores it). The list is part of your saved style: GET /api/v1/style returns it as channels, [{ "key": "lobby", "name": "Lobby" }].
Voice rooms work the same way
The Voice screen has its own room list, in the same style as the chat's: the + next to Voice rooms opens the same Join / Create new pop-up, a voice room gets a code like #0E0E-0E0E, and Leave room sits at the bottom of the list. Voice rooms and chat rooms are separate lists, so a chat room never shows up on the Voice screen or the other way round. In the chat designer, Voice rooms everyone can join lists up to twelve voice rooms of your own, saved in the style as voice_channels ([{ "key": "lounge", "name": "Lounge" }]). If you list none, voice stays the voice of whichever chat room is open, as before. Over HTTP, POST /api/v1/rooms with {"name":"Squad call","voice":true} makes a private voice room (its key starts with vroom: and the room carries "voice": true); joining and leaving use the same /rooms/join and /rooms/leave, and a code opens either kind. In the SDK, nx.createRoom("Squad call", { voice: true }). Chat and voice rooms count toward the same limit of 20 private rooms per user.
The full app: rooms from every game
The full app on astralink.nexus lists every room the signed-in user is in, from every game, with the website's own rooms first and each other game's rooms under the game's name. Once the list is long, a search box finds a room by part of its name. Opening a room from another game shows that game's own chat over the app with a Back button. In your own app, Astralink.mount(el, { client, directory }) does the same: directory returns (a promise of) { games: [{ name, public_key, token_url, rooms: [{ key, name, code }] }] }, and token_url answers { token } for that game. The search box also appears by itself when one game has more than six rooms; the Voice screen lists the voice rooms (flagged voice: true) in the same way, and a voice room of another game opens that game's Voice screen.
Inbox and email
Every user account has an inbox and an address, [email protected]. The inbox is a full mail client that Astralink hosts: the taskbar's Inbox tab shows it in a frame. It is private from your game. It is another website, so your game's code cannot read a user's mail; the page only sends back how many messages are unread, for the badge on the taskbar. Users sign in inside the inbox with their Astralink account (or are signed in already if they use astralink.nexus).
Mail from your game. Send updates, patch notes or rewards to users who have signed in to Astralink in your game, using your secret key and the same id you use for them (their external_id):
curl -X POST https://www.astralink.nexus/api/v1/mail/game -H "Authorization: Bearer sk_YOUR_SECRET_KEY" -H "Content-Type: application/json" -d '{"to_external_ids":["player-42","player-7"],"subject":"Patch notes","body":"New dungeon!","from_name":"Studio Updates"}'
# {"sent":1,"results":[{"external_id":"player-42","status":"sent"},{"external_id":"player-7","status":"not_linked"}]}
Statuses are sent and not_linked (that user has not signed in to Astralink in your game, so there is no inbox to send to; try again later). sent is all you ever learn: it does not say whether the message arrived, was held for a parent, or was dropped. Up to 50 users per call. The message shows a Game tag with your from_name (your project's name if you leave it out); a name containing "Astralink" is not allowed.
Rules. Adult users can write to each other (up to 5 people per message). A user under 18 has full email or none, as their parent decides on their dashboard (from an age they choose, we suggest 13): with it they write and receive like anyone, without it they have no inbox at all. Everything sent to such a child (from users, games or outside providers) waits for a parent to approve it before they can see it. Nobody who writes to a user is told more than "sent": not whether it arrived, was held, or whether the address exists. Users can block other users, who are not told. Mail is plain text. Adult users can also receive email from other providers at [email protected]. It shows an Outside email tag, with a warning when the sender could not be verified; it is shown as plain text, attachments are listed but not shown, and a user under 18 only gets it if a parent allows email and approves it. Replying to outside email and sending to other providers are not available yet.
To place the inbox yourself: Astralink.inboxPanel(nx, { colors: { bg: "#1e1f22", panel: "#2b2d31", text: "#dbdee1", accent: "#5865f2" }, onUnread: function (n) {} }).el. Your website must be in the project's allowed origins to frame it.
Voice chat
Every channel has a voice room with the same key and the same access rules (a private channel's voice room is only for its members). Turn it on per project with Allow voice chat in the project settings. Voice runs on LiveKit, a media server built for large numbers of rooms; the audio goes directly between users and that server, not through this API.
The ready-made chat has a Voice tab with a join button, who is in the room, a speaking indicator, and mute and leave. Voice options (how you talk, a microphone test) live in Settings, a gear icon at the end of the taskbar, which will also hold other settings. You can add your own sections to it with Astralink.mount(...).settings.addSection("Title", element), or place the whole screen anywhere with Astralink.settingsPanel(nx).el. To build your own voice interface, the SDK exposes:
await nx.joinVoice("scene:forest"); // asks for the microphone; stays a listener if it is refused
await nx.joinVoice("scene:forest", { mic: false }); // join as a listener; the microphone is only asked for on unmute
nx.on("voice", function (s) { /* s.state, s.muted, s.deaf, s.participants[{ name, speaking, muted, me }] */ });
await nx.setMicMuted(true); // mute or unmute yourself
await nx.setDeafened(true); // stop hearing everyone (and mute yourself)
nx.setParticipantMuted(id, true); // mute one person for yourself only
await nx.leaveVoice();
The voice screen is also available on its own, to place anywhere in your page: Astralink.voicePanel(nx, { channel: "scene:forest" }).el. It includes a live microphone meter, so users can see their microphone working, and a Test mic button that records a few seconds on their device and plays it back so they can hear themselves. Nothing from the test is sent anywhere.
Speak modes
Each user chooses how they talk in Settings, the gear icon at the end of the taskbar. Their choice is remembered in their browser.
- Voice activated (default): the microphone opens when the user speaks and closes shortly after. A sensitivity slider with a live level bar lets them tune it.
- Push to talk: the microphone is open only while the talk button or the Space bar is held.
- Open mic: always transmitting while unmuted.
Astralink.init({ publicKey: "pk_...", guest: true, speakMode: "ptt" }); // your default; the user's own choice wins
nx.setSpeakMode("vad", { sensitivity: 70 }); // "vad" | "ptt" | "open"
nx.pttDown(true); /* ...and nx.pttDown(false) on release: for your own talk key or button */
The user's own mute always beats every mode. Switching modes is instant and never asks for the microphone again.
How loud each user sounds (proximity chat and more)
Your game decides how loud each user should be heard: by distance for proximity chat, by team, silent for a spectator, and so on. Astralink does not make that decision, it gives your game the control. Tell the SDK a volume from 0 (silent) to 1 (full) for any user, using the same id your game used for them (their external_id).
nx.setPlayerVolume("player-42", 0.35);
nx.setPlayerVolumes({ "player-42": 0.35, "player-7": 0 }); // many at once; add { replace: true } to forget everyone not listed
nx.setDefaultVolume(0); // everyone you have not set (default 1)
nx.setPlayerVolume("player-42", null); // back to the default for that user
nx.clearPlayerVolumes(); // everyone back to full volume
// proximity chat is then just your own rule, run as often as your game likes:
for (const other of nearbyPlayers) nx.setPlayerVolume(other.id, myFalloff(distanceTo(other)));
Call as often as you like, even every frame: updates are batched. It works before or after users join the room, and it combines with each user's own "mute this person" and deafen. The voice screen shows a small volume bar under anyone your game has turned down.
Other platforms call POST /api/v1/voice/join with a user token and connect with the returned url and token using LiveKit's SDK for Unity, Android, iOS or the web. The token is good for one room, lets the user listen, and lets them speak unless a moderator muted them in that channel.
Podcast (the radio dial)
You choose the channels, and your users tune between them like a radio: previous and next to move along the dial, or Scan to hear a few seconds of each channel until they press Stay here on one they like. In your project's page (account, API), the Podcast channels section is where you add them. A channel is either:
- A podcast: the address of its RSS feed. Astralink reads the feed (it checks again about every 6 hours, or press Refresh) and plays the newest episodes, one after another. The channel takes the feed's own title and picture unless you give it a name.
- A live radio stream: the address of an audio stream (for example an Icecast or Shoutcast MP3 stream), plus a name.
Astralink does not host or relay the audio: each user's browser plays it straight from the address you gave, so you pay for that bandwidth with whoever hosts it, and the audio must be on a public https address. You can have up to 20 channels, reorder them, and hide one without deleting it. Addresses must be on the normal web ports and publicly reachable; Astralink refuses addresses that point inside a private network.
The Podcast module appears in the taskbar when it is allowed in Taskbar and modules. It keeps playing while a user looks at other tabs, shows a green dot on the tab, and stops when the user switches the podcast off with /podcast off or in Settings. To place the dial yourself:
const dial = Astralink.podcastPanel(nx, { scanSeconds: 8 }); // nx = Astralink.init({ publicKey: "pk_..." })
document.getElementById("radio").appendChild(dial.el);
dial.show(); // loads the channels (call it when the dial first appears)
// dial.next(), dial.prev(), dial.scan(), dial.stay(), dial.play(), dial.pause(), dial.tune(2)
Other platforms call GET /api/v1/podcast/channels with your public key and play the returned addresses with their own audio player. Each podcast channel has its newest episodes (title, audio, duration); a stream channel has one stream address.
Live broadcast (users on air)
Besides podcasts and streams, a channel can be a live broadcast: one of your users speaks into it and everyone tuned to the channel hears them live. Use it for an in-game radio station with a microphone object, a host answering questions on a blog, a game show: Astralink gives you the tools and you decide the rules. Add one in the project page under Podcast channels (type Live broadcast). Only one person is on air at a time; anyone else who tries is told the channel is busy. If a broadcaster's page closes, the channel goes off air by itself within about 25 seconds. Listeners see the channel as On air or Off air on the dial, and the scan skips empty ones.
Who may go on air
You choose per channel: any signed-in user, or only users your server gives a permit (the default, and the right choice for a game). A permit lasts a few minutes (10 by default, 24 hours at most) and your server can take it back at any time. For example, give it when the user reaches the radio booth and revoke it when they walk away:
curl -X POST https://www.astralink.nexus/api/v1/podcast/channels/7/permits -H "Authorization: Bearer sk_YOUR_SECRET_KEY" -H "Content-Type: application/json" -d '{"external_id":"player-42","ttl_seconds":600}'
curl -X DELETE https://www.astralink.nexus/api/v1/podcast/channels/7/permits/player-42 -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
# a show already running ends at its next check-in, within about 10 seconds
Each channel's number is shown next to its name in the project page (Podcast channels, "channel 7"), and it is the id of the channel in GET /api/v1/podcast/channels. A user's external_id is the same id you use for them everywhere else.
Going on air from the browser
const studio = Astralink.studio({ duck: true }); // the mixer: microphone, files and shared sound become one track
await studio.startMic(); // asks for the microphone (needs an https page and a click)
const show = await nx.goLive(7, { studio, title: "Ask me anything" });
show.on("ended", (e) => console.log("off air:", e.reason)); // "stopped", "permit_ended", "not_on_air", "disconnected", "network"
// ...later
show.stop();
The user token you use must stay valid for as long as the show lasts (the project page's Token lifetime goes up to 24 hours). For a ready-made control screen with the Go on air button, the microphone, the file player and the mixer, place Astralink.studioPanel(nx, { channel: 7 }); leave out channel and it offers the project's live channels. It is optional: everything it does is a method on studio, so you can build your own, such as a microphone object in a game that calls startMic() and goLive().
The studio
- Microphone:
startMic(deviceId?),stopMic(),setMicMuted(true),micDevices(). - Audio files:
studio.library.add(file)stores a file on that user's device only (nothing is uploaded to Astralink), up to 200 MB each and 1 GB in total by default. ThensetQueue(ids),play(),pause(),stop(),next(),prev(),seek(seconds),setLoop("off" | "all" | "one"),setShuffle(true)andfadeOut(3). The library lists withstudio.library.list(), and removes withremove(id). Files work on every device, phones included, so they are the way to put music on air from a phone. - Sound from the computer:
studio.canShareAudio()tells you whether this browser can share a tab's or the computer's sound (desktop Chrome and Edge; on Mac only a tab's sound; not phones, Firefox or Safari), andstudio.shareAudio()asks the user to pick one and tick Share audio. - Your own sound:
studio.addStream(mediaStream)mixes any MediaStream, such as a game's audio. - Mix:
setVolume("mic" | "music" | "system" | "master", 0 to 1),setDucking(true, 0.25)to lower the music while the microphone hears speech,setMonitor(false)to stop the broadcaster hearing their own music, andlevels()for meters. The microphone is never played back to the broadcaster. Tell broadcasters to use headphones, so the microphone doesn't pick up the music.
Listening
The dial in the taskbar plays live channels with no extra work. To build your own listener, call nx.podcastListen(7): it returns the media server address and a listen-only token, or the error off_air. Other platforms call POST /api/v1/podcast/live/listen with the public key and connect with LiveKit's SDK for Unity, Android, iOS or the web. The broadcaster side on other platforms uses POST /api/v1/podcast/live/start with a user token, publishes one audio track to the returned room, and calls POST /api/v1/podcast/live/heartbeat every 10 seconds and POST /api/v1/podcast/live/stop at the end.
Music and rights
Playing music on a live broadcast is a public performance. Commercial music from streaming services is generally not licensed for that and their terms forbid it. You and your broadcasters are responsible for having the rights to anything put on air: use music you own, have licensed, or that is royalty free.
Moderation (your own tools)
Astralink does not moderate for you and does not decide who your moderators are. If you want moderators or staff, you create them in your own game or website with your own rules, and your server calls the actions below with the project's secret key. The actions only ever apply inside your project: a user you ban is not banned from anyone else's game.
Separately, Astralink's own safety system looks for threats to children and sends alerts to their parents. It may also send you a short notice that a threat was found; what that notice contains is still being decided. You never receive a report queue, and nobody at Astralink reviews your chat by hand.
Mute, kick and ban
curl -X POST https://www.astralink.nexus/api/v1/moderation/restrictions -H "Authorization: Bearer sk_YOUR_SECRET_KEY" -H "Content-Type: application/json" -d '{"external_id":"player-42","kind":"mute","reason":"spam"}'
# kind "mute": the user can't write, speak in voice or go on air. Add "channel":"scene:forest" to mute only there.
# kind "kick": out of one channel ("channel" is required) for "minutes" (10 if you leave it out). They can't rejoin until then.
# kind "ban": every call this user makes is refused, everywhere in your project, and an open connection is closed.
# Add "minutes":60 to any of them to end it by itself; a mute or ban without it lasts until you lift it.
curl "https://www.astralink.nexus/api/v1/moderation/restrictions?external_id=player-42" -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
curl -X DELETE "https://www.astralink.nexus/api/v1/moderation/restrictions/player-42?kind=mute" -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
# add &channel=scene:forest to lift a channel mute or a kick
A user who is restricted gets a clear error: muted, kicked or banned (with when it ends, if it does). Users who are connected over the WebSocket receive {"op":"kicked","channel":"...","reason":"kicked" | "banned"} straight away; a ban also closes the connection. A voice call or live show that is already running is not cut: it ends when the user leaves, and they can't join or go on air again while the restriction lasts.
Reading and deleting messages
curl "https://www.astralink.nexus/api/v1/moderation/channels/scene:forest/messages?limit=50" -H "Authorization: Bearer sk_YOUR_SECRET_KEY"
# newest first page, oldest first inside it; add before=SEQ or after=SEQ to page. Each message has the author's external_id, and deleted ones keep their text for you.
curl -X POST https://www.astralink.nexus/api/v1/moderation/messages/delete -H "Authorization: Bearer sk_YOUR_SECRET_KEY" -H "Content-Type: application/json" -d '{"channel":"scene:forest","seq":1042}'
# everyone watching the channel sees the message disappear; users only ever see "deleted", never the text
The built-in filter
In your project's page, Block links, email addresses and phone numbers rejects messages containing them, including disguised forms such as "name (at) site (dot) com". The sender is told why. It is recommended for any chat with children, and it is off until you turn it on.
Endpoints
| Method | Path | Who can call it | What it does |
|---|---|---|---|
| GET | /api/v1/health | Nobody | Check that the API is reachable. |
| POST | /api/v1/tokens | Secret key | Your server vouches for a user (external_id, display_name) and receives a short-lived user token. |
| POST | /api/v1/guest | Public key | A visitor with no identity is given a random name like UserK7M2Q9XA (or the one they chose). Only when the project uses random names. |
| POST | /api/v1/me/name | User token | A visitor who was given a random name chooses their own. Refused for people the game named or who are logged in with an account. |
| PUT | /api/v1/users/{external_id} | Secret key | Your own name provider: create a person or change their display_name or avatar_url without signing them in. |
| GET | /api/v1/users/{external_id} | Secret key | Who a person is in your project. |
| GET | /api/v1/me | User token | Who the token belongs to, and whether a private account is linked. |
| GET | /api/v1/style | Public key | The project's chat style: preset, full or compact layout, window size, colors and which elements to show, with the project's taskbar and module settings already applied (taskbar: false means draw no taskbar). |
| GET | /api/v1/account/username | Public key | Check a username (?name=) and see the email address it would become. |
| POST | /api/v1/account/register | Public key | Step 1 of sign-up: username, password and age (a plain number) are required, plus email for adults or parent_email for under 18. A 6-character code is emailed; nothing is created yet. |
| POST | /api/v1/account/confirm | Public key | Step 2 of sign-up: the emailed code creates the private account and returns an account token. For under 18 the code goes to the parent, who also gets a free parent account. |
| POST | /api/v1/account/resend | Public key | Send a fresh sign-up code (limited to a few, a minute apart). |
| POST | /api/v1/account/login | Public key | A user logs in manually with username and password and receives an account token. |
| POST | /api/v1/account/setup | Setup token | First sign-in of an account a parent made: login answers 403 setup_required with a setup_token; send it with the username and password the child chose to get an account token. |
| POST | /api/v1/account/link | User token + account token | Sync the private account with the public ID the game assigned. |
| POST | /api/v1/account/logout-all | Public key + account token | Sign the account out on every device. |
| GET | /api/v1/channels | User token | The user's channels, with unread counts. |
| POST | /api/v1/channels | Secret key | Create a group or public channel with an explicit member list. |
| POST | /api/v1/channels/join | User token | Join a channel by key. Public channels are created on first use. |
| POST | /api/v1/dm | User token | Open a private direct-message channel with another user. |
| POST | /api/v1/mail/game | Secret key | Send mail to users who signed in to Astralink in your game: to_external_ids, subject, body, from_name. Each user gets a status (sent, not_linked). |
| GET | /api/v1/mail/summary | Account token | The signed-in user's address, unread count and folder totals. Used by the hosted inbox page (your game cannot read mail). |
| GET | /api/v1/mail/list | Account token | A folder of the user's mail: inbox, sent, starred or trash, newest first. |
| POST | /api/v1/mail/send | Account token | A user writes to other users' Astralink addresses (adults, and children whose parent has turned email on). The answer is always just "sent". |
| GET | /api/v1/podcast/channels | Public key | The radio dial: the podcast and live-stream channels you chose for the project, in order, with each podcast's newest episodes (title, audio address, length). |
| POST | /api/v1/podcast/live/start | User token | Go on air on a live channel (needs a permit from your server, or the channel set to any signed-in user). Returns the media server address and a publish token. One broadcaster per channel. |
| POST | /api/v1/podcast/live/heartbeat | User token | The broadcaster checks in every 10 seconds. Answers with an error when the permit ended or someone else has the channel. |
| POST | /api/v1/podcast/live/stop | User token | Come off air. |
| POST | /api/v1/podcast/live/listen | Public key | Listen to a live channel: returns the media server address and a listen-only token, or the error off_air. |
| POST | /api/v1/podcast/channels/{id}/permits | Secret key | Let one of your users (by external_id) go on air on a live channel for ttl_seconds (default 600, at most 24 hours). |
| DELETE | /api/v1/podcast/channels/{id}/permits/{external_id} | Secret key | Take the permit away; a running show ends within about 10 seconds. |
| POST | /api/v1/rooms | User token | A user creates a private room (name) and joins it. The answer includes its code, like #0E0E-0E0E, to share. |
| POST | /api/v1/rooms/join | User token | Join a private room by its code. The user stays in it until they leave. |
| POST | /api/v1/rooms/leave | User token | Leave a private room. When the last member leaves, the room and its messages are deleted. |
| POST | /api/v1/moderation/restrictions | Secret key | Mute, kick or ban one of your users: external_id, kind (mute, kick, ban), channel, minutes, reason. Applies only inside your project. |
| GET | /api/v1/moderation/restrictions | Secret key | Who is muted, kicked or banned right now (?external_id= for one user). |
| DELETE | /api/v1/moderation/restrictions/{external_id} | Secret key | Lift a mute, kick or ban: ?kind=mute|kick|ban, plus &channel= for a channel mute or a kick. |
| GET | /api/v1/moderation/channels/{key}/messages | Secret key | Read a channel's messages for review, deleted ones included, with each author's external_id. |
| POST | /api/v1/moderation/messages/delete | Secret key | Delete anyone's message: channel and seq. Everyone watching sees it disappear. |
| POST | /api/v1/voice/join | User token | Join the voice room of a channel: returns the media server address and a short-lived room token (voice must be on for the project). |
| GET | /api/v1/channels/{key}/messages | User token | History, newest page by default; use after, before and limit to page. |
| POST | /api/v1/channels/{key}/messages | User token | Send a message (up to 2000 characters). |
| DELETE | /api/v1/channels/{key}/messages/{seq} | User token | Delete one of your own messages. |
| POST | /api/v1/channels/{key}/read | User token | Mark a channel read up to a message number. |
| GET | /api/v1/channels/{key}/members | User token | Who is in the channel right now (connected, not everyone who ever joined). Each member has a guest flag: true for a visitor chatting without an account. |
History uses a message number (seq) that increases by one in each channel. After a reconnect, ask for ?after=LAST_SEQ to catch up without gaps.
WebSocket (live messages)
Connect to wss://www.astralink.nexus/api/v1/ws?token=USER_TOKEN. Frames are JSON.
// you send
{"op":"join","channel":"scene:forest","after":42}
{"op":"send","channel":"scene:forest","text":"hello","cid":"abc"}
{"op":"typing","channel":"scene:forest"}
{"op":"read","channel":"scene:forest","seq":43}
// you receive
{"op":"ready","user":{...}}
{"op":"joined","channel":{...},"messages":[...],"count":12}
{"op":"message","channel":"scene:forest","seq":43,"text":"hello","user":{...}}
{"op":"ack","cid":"abc","seq":43}
{"op":"typing","channel":"scene:forest","user":{...}}
{"op":"presence","channel":"scene:forest","count":12}
{"op":"error","code":"rate_limited","message":"..."}
Errors and limits
Errors return a non-2xx status and a body like {"error":{"code":"invalid_token","message":"..."}}. Branch on code, which stays stable.
- Messages are limited to 2000 characters; excess requests get
429 rate_limited. - User tokens expire (default one hour, set per project). Ask your server for a fresh one when you get
401 invalid_token. - Direct-message and group channels are private to their members; public channels are open to everyone in your project.
Questions? Safe chat for kids covers the parent dashboard, and the FAQ covers the rest.