Post to X
Connect your own X developer app to post through the official API.
To post to X from Wings, bring your own X developer app. Wings does not provide a shared X app.
1. Connect X
- Create a Project and App in the X Developer Console.
- Set the App's user authentication permissions to Read and write.
- Find the API Key and API Key Secret.
- Generate an Access Token and Access Token Secret after setting those permissions.
- Copy a JSON object containing the four values to your clipboard. Use the keys
api_key,api_key_secret,access_token, andaccess_token_secret.
Regenerate tokens created with read-only permissions. The Developer Console issues tokens for the App owner's account.
wings connection add x-main --preset x_oauth1
2. Save the code
Save this as post-to-x.js.
It posts the text you pass in event.text.
export default async function (event) {
const response = await fetch('https://api.x.com/2/tweets', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: event.text }),
agiWings: { connection: 'x' },
})
if (!response.ok) throw new Error('X request failed')
return response.json()
}
3. Deploy and post
wings handler deploy --name post-to-x --file post-to-x.js --connection x=x-main
wings handler list
The next command publishes a real post to X. Check the text and cost first, then use the ID from the list:
wings run <handler-id> --event '{"text":"Hello from Wings"}'
wings handler logs <handler-id>
Check X to confirm that exactly one post was created. If the Run fails, check whether the post appeared before trying again. Repeating the command can create a duplicate post.
Authentication and cost
Wings signs each request to api.x.com with OAuth 1.0a / HMAC-SHA1.
It replaces any Authorization header supplied by the code.
Use the v2 API on api.x.com for media uploads too.
X bills the developer app owner for API use. Check X's current prices and permission requirements. Agree on the posting frequency and cost before adding a Schedule.