Open this on a computer

The Sample Bot API site is made for a computer, where you write code. Visit api.samplebot.app on your computer.

Back to samplebot.app

Sample Bot API

Bot API

Read and change what Sample Bot does in a server, from your own code. 103 endpoints across 17 areas, plus 65 webhook events.

https://api.samplebot.app/v1/servers/{server id}/...

Connecting a server

A key on its own reaches nothing. For your application to work on a server:

  1. Give the server's admin your application ID (on Your application).
  2. They open config.samplebot.app, pick the server, open API, paste the ID and tick what your application may do.
  3. Your application can now call that server, for those things only. GET /v1/me lists the servers it is connected to.

The admin can change the ticks or disconnect your application at any time. Everything your application changes appears in the server's audit log as via API: your application's name, and actions are done in the name of the admin who connected it.

Where an action needs a person (claiming or closing a ticket), you name them with userId, and their own permissions are checked, exactly as if they pressed the button.

Permissions (scopes)

ScopeLets the application
server:readSee the server name, member count, channels and roles
sessions:readSee sessions and session votes
sessions:writeStart, change and end sessions and votes
shifts:readSee shifts, who is on duty and the leaderboard
shifts:writeStart and end shifts, breaks, and add time
tickets:readSee tickets
tickets:writeClaim, unclaim and close tickets
moderation:readSee moderation cases and in-game moderation
moderation:writeWarn members, file in-game kicks and bans, decide BOLOs
cad:read PlusSee CAD calls, units, records and characters
cad:write PlusCreate calls and records, change unit status
erlc:readSee the game server, players and logs
erlc:writeRun commands in the game server
regions:readSee areas and who is in them
regions:writeDraw and delete areas
automations:readSee automations
automations:write PlusRun automations and switch them on or off
applications:readSee application forms and submissions
applications:writeAccept and deny applications
members:readLook up members and their linked Roblox accounts
giveaways:readSee giveaways
giveaways:writeEnd and reroll giveaways
loa:readSee leave of absence
loa:writeApprove and deny leave
suggestions:readSee suggestions
suggestions:writeApprove and deny suggestions
staff:readSee staff requests, trainings, activity checks and roleplay requests
staff:writeApprove and deny roleplay requests
directory:readSee this server's directory listing
audit:readSee this server's audit log

Example

// Who is on shift right now?
const res = await fetch("https://api.samplebot.app/v1/servers/" + SERVER_ID + "/shifts/active", {
  headers: { Authorization: `Bearer ${process.env.SAMPLE_API_KEY}` },
});
const { ok, data, error } = await res.json();
if (!ok) throw new Error(error.message);
console.log(data);

Endpoints

Server

GET /The server: name, members, Plus, and what this app may do here.
GET /channelsText channels the bot can see.
GET /rolesRoles, highest first.
GET /featuresWhich Sample Bot features are switched on.

Sessions and votes

GET /sessions/activeThe session running now, or null.
GET /sessionsPast and present sessions, newest first.
GET /sessions/:idOne session.
POST /sessions/startStart a session in the session channel.
POST /sessions/statusMark the session ACTIVE, FULL or BOOST.
POST /sessions/endEnd the session (and any open vote).
GET /votes/activeOpen session votes, with how many have voted.
GET /votesPast votes, newest first.
POST /votes/startOpen a public session vote.
POST /votes/:id/cancelCall a vote off.

Shifts

GET /shifts/activeWho is on shift or on break right now.
GET /shiftsShifts, newest first. Filter by userId.
GET /shifts/leaderboardThis week's time on duty, most first.
GET /shifts/users/:userIdOne person: their open shift and this week's total.
POST /shifts/startPut someone on shift.
POST /shifts/endEnd someone's shift.
POST /shifts/break/startPut someone on break.
POST /shifts/break/endBring someone back from break.
POST /shifts/creditAdd time to someone's week.

Tickets

GET /ticketsTickets. Open and claimed by default; status=CLOSED for closed ones.
GET /tickets/statsCounts: open, claimed, closed this week.
GET /tickets/:idOne ticket.
POST /tickets/:id/claimClaim a ticket as a staff member. Their own permissions are checked.
POST /tickets/:id/unclaimLet a claimed ticket go.
POST /tickets/:id/closeClose a ticket with a transcript, as a staff member allowed to.

Moderation

GET /casesModeration cases, newest first. Filter by userId or kind.
GET /cases/:numberOne case, by its number.
GET /cases/users/:userIdSomeone's record: every case and a count by kind.
POST /cases/warnWarn a member. Logged and sent to them like a /warn.
POST /cases/:number/voidVoid a case.
GET /game-moderationIn-game warnings, kicks, bans and BOLOs filed through Sample Bot.
POST /game-moderationFile an in-game warning, kick, ban or BOLO. Kicks and bans run in the game.
GET /game-moderation/bolosBOLOs waiting for a decision.
POST /game-moderation/bolos/:id/approveApprove a BOLO, which bans the player in game.
POST /game-moderation/bolos/:id/declineDecline a BOLO.

CAD (Plus)

GET /cad/callsOpen calls. closed=true to include closed ones.
GET /cad/calls/:idOne call, with its units and notes.
POST /cad/callsCreate a call on the board.
POST /cad/calls/:id/notesAdd a note to a call.
POST /cad/calls/:id/closeClose a call and free its units.
POST /cad/calls/:id/assignAttach a unit to a call.
GET /cad/unitsUnits signed on now.
GET /cad/units/:idOne unit.
POST /cad/units/:id/statusChange a unit's status (10-8, 10-6, 10-7, 10-97, 10-23, 10-11, 10-15).
GET /cad/alertsActive warrants and BOLOs.
GET /cad/recordsRecords, newest first. Filter by citizenId, kind or plate.
GET /cad/records/:idOne record.
POST /cad/recordsWrite a record: citation, arrest, warrant, BOLO or incident.
GET /cad/searchSearch characters, plates and records.
GET /cad/citizens/:idOne character with licences, vehicles and records.
GET /cad/plates/:plateRun a plate.
GET /cad/feedThe CAD's live feed: joins, downs, stops, mod calls (last 7 days).
GET /cad/bodycamsRecent bodycam recordings and who they belong to.

In game (ER:LC)

GET /erlc/serverThe game server: name, code, players, queue.
GET /erlc/playersPlayers in game, with team and callsign.
GET /erlc/positionsWhere each player is on the map, with the nearest postal.
GET /erlc/queuePlayers waiting to join.
GET /erlc/vehiclesSpawned vehicles.
GET /erlc/joinsJoin and leave log.
GET /erlc/killsKill log.
GET /erlc/commandsCommand log.
GET /erlc/modcallsMod call log.
GET /erlc/bansPlayers banned from the game server.
POST /erlc/commandRun a command in the game server, for example ":h Server restart in 5 minutes".

Areas

GET /regionsAreas drawn on the map.
GET /regions/:idOne area, with who is in it now.
POST /regionsDraw an area from map points.
DELETE /regions/:idDelete an area.

Automations

GET /automationsAutomations in this server.
GET /automations/:numberOne automation.
POST /automations/:number/runRun an automation now, with optional values for its text.
POST /automations/:number/enabledSwitch an automation on or off.

Applications

GET /applicationsApplication forms.
GET /applications/submissionsSubmissions. status=PENDING, ACCEPTED or DENIED.
GET /applications/submissions/:idOne submission with its answers.
POST /applications/submissions/:id/decideAccept or deny. Roles and messages happen as they do in Discord.

Members

GET /members/:userIdA member: name, roles, when they joined, their Roblox account.
GET /members/by-roblox/:robloxIdWhich member of this server owns a Roblox account. Only members of this server are found.
GET /members/by-roblox-name/:nameThe same, by Roblox username.

Giveaways

GET /giveawaysGiveaways, running first.
GET /giveaways/:idOne giveaway.
POST /giveaways/:id/endEnd a giveaway now and pick winners.
POST /giveaways/:id/rerollPick new winners.

Leave of absence

GET /loaWho is on leave now.
GET /loa/requestsLeave requests waiting for a decision.
GET /loa/users/:userIdSomeone's leave history.
POST /loa/:id/decideApprove or deny a leave request.
POST /loa/:id/endEnd someone's leave early.

Suggestions

GET /suggestionsSuggestions, newest first. status=PENDING, APPROVED or DENIED.
GET /suggestions/:idOne suggestion with its votes.
POST /suggestions/:id/reviewApprove or deny a suggestion.

Staff team

GET /staff/requestsRecent calls for staff in game.
GET /staff/trainingsTrainings, newest first.
GET /staff/activity-checksActivity checks, newest first.
GET /staff/activity-checks/:idOne activity check: who answered and who has not.
GET /roleplay-requestsRoleplay requests. status=PENDING, APPROVED or DENIED.
POST /roleplay-requests/:id/decideApprove or deny a roleplay request.

Directory

GET /directoryThis server's directory listing, bumps and position.

Audit log

GET /auditThe server's audit log, including what apps did.

Not in the API, on purpose

Bumping and voting in the server directory, giving out staff permissions in game, and changing the bot's setup. These stay with people in Discord.