Setu Recipes: reusable workflows across every app.Browse templates

Integrations / X

X

Social network (formerly Twitter): look up accounts, read and search posts, publish and delete posts.

8 actions OAuth 2 5 read2 write1 destructive Calls api.x.com

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "x" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

ScopeWhy it is requested
tweet.readRead posts, including those you can see
users.readRead profiles and identify the connected account
tweet.writeCreate and delete posts on your behalf
offline.accessStay connected without asking you to sign in again

Actions

Create postwritex.create_postPublish a text post as the connected X account. Needs a paid X API access tier.

Needs scopes: tweet.write, tweet.read, users.read

InputTypeDescription
textstringRequiredPost text
reply_settingsstringOptional
TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.create_post",
  input: {
    "text": "<text>"
  },
});
Delete postdestructivex.delete_postPermanently delete one of the connected account's own posts by id.

Needs scopes: tweet.write, tweet.read, users.read

InputTypeDescription
idstringRequiredId of the post to delete
TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.delete_post",
  input: {
    "id": "<id>"
  },
  confirm: true,
});
Get my profilereadx.get_meGet the profile of the connected X account (id, name, username).

Needs scopes: tweet.read, users.read

No input.

TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.get_me",
  input: {},
});
Get postreadx.get_postGet a single post by its id, including its text and author id.

Needs scopes: tweet.read, users.read

InputTypeDescription
idstringRequiredPost id (digits)
TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.get_post",
  input: {
    "id": "<id>"
  },
});
Get user by usernamereadx.get_user_by_usernameLook up an X account by its username (without the @) to get its numeric id and name.

Needs scopes: tweet.read, users.read

InputTypeDescription
usernamestringRequiredUsername without the @, 1 to 15 letters, digits or underscores
TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.get_user_by_username",
  input: {
    "username": "<username>"
  },
});
Get a user's postsreadx.get_user_postsGet recent posts from an account's timeline by numeric user id; can skip replies and reposts.

Needs scopes: tweet.read, users.read

InputTypeDescription
idstringRequiredNumeric user id
max_resultsintegerOptional5 to 100
excludearray of stringOptional
pagination_tokenstringOptional
TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.get_user_posts",
  input: {
    "id": "<id>"
  },
});
Reply to postwritex.reply_to_postPublish a reply to an existing post as the connected X account. Needs a paid X API access tier.

Needs scopes: tweet.write, tweet.read, users.read

InputTypeDescription
textstringRequired
in_reply_to_post_idstringRequiredId of the post being replied to
TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.reply_to_post",
  input: {
    "text": "<text>",
    "in_reply_to_post_id": "<in_reply_to_post_id>"
  },
});
Search recent postsreadx.search_recent_postsSearch posts from the last 7 days with an X search query (for example: from:user -is:retweet). Needs a paid X API access tier.

Needs scopes: tweet.read, users.read

InputTypeDescription
querystringRequiredX search query, 1 to 4096 characters
max_resultsintegerOptionalResults to return, 10 to 100 (default 10)
sort_orderstringOptional
TypeScript
await setu.execute({
  userId: "user_1",
  action: "x.search_recent_posts",
  input: {
    "query": "<query>"
  },
});