Search... Ctrl + K

Post status (mastodon)
One script reply has been approved by the moderators Verified

Created by jaller94 122 days ago Used 30 times 1 Point

Create a new toot. A required parameter are a mastodon resource with an accessToken and "status" (text content). Optional parameters are an array of media files (base64 encoded), a boolean flag "sensitive", a string "spoiler_text", a string "inReplyToId", an ENUM["public","unlisted","private","direct"] "visibility", an ISO 8601 datetime "scheduledAt" and an ISO 639 language code "language". It should return the JSON object that the API responds.

No comments yet

Points: 0
One script reply has been approved by the moderators
export async function main(
  baseUrl: string,
  accessToken: string,
  status: string,
  inReplyToId?: string,
  sensitive = false,
  spoilerText?: string,
  visibility: "public" | "unlisted" | "private" | "direct" = "public",
  language?: string,
) {
  const resp = await fetch(`${baseUrl}/api/v1/statuses`, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${accessToken}`,
      "Content-Type": "application/json",
    body: JSON.stringify({
      ...(inReplyToId && {
        in_reply_to_id: inReplyToId,
      ...(spoilerText && {
        spoiler_text: spoilerText,
      ...(language && {

  if (!resp.ok) {
    throw Error(`Failed to post status: Error HTTP${resp.status}`);

  return await resp.json();

Submitted by jaller94 122 days ago

Edited 122 days ago

No comments yet