Slack OAuth
Available scopes
Section titled “Available scopes”| Resource | Operation | Scope |
|---|---|---|
| Messaging | Send message | chat:write, users:read |
| Messaging | Read messages | channels:history, groups:history |
| Users | Get user info / list users | users:read |
| Channels | List channels | channels:read |
| Channels | Join channel | channels:join |
| Files | Upload file | files:write |
| Files | Read files | files:read |
| Reactions | Add/read reactions | reactions:write, reactions:read |
Example — post a message
Section titled “Example — post a message”class Workflow { async start(data, headers, api) { // data IS the order object for orders/* webhook topics const { token } = await api.getOAuthToken('my-slack');
await fetch('https://slack.com/api/chat.postMessage', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}`, }, body: JSON.stringify({ channel: '#orders', blocks: [ { type: 'section', text: { type: 'mrkdwn', text: `*New order* #${data.order_number} — ${data.total_price} ${data.currency}`, }, }, ], }), }); }}Example — upload a file
Section titled “Example — upload a file”const formData = new FormData();formData.append('channels', '#reports');formData.append('content', csvString);formData.append('filename', 'report.csv');
const { token } = await api.getOAuthToken('my-slack');await fetch('https://slack.com/api/files.upload', { method: 'POST', headers: { Authorization: `Bearer ${token}` }, body: formData});