Let OpenClaw run your Spotify playlists
You hear a song you like, you mean to save it, and it is gone by the time you open the app. The playlists you started with good intentions drift out of date, and the "make me something new" feeling usually loses to the friction of building it. Connect the Spotify Web API and your Operator.io agent takes over the upkeep: you mention a track in your channel and it lands in the right playlist, and once a week it puts together a mix from what you have been playing.
The agent calls Spotify's REST endpoints with OAuth 2.0 bearer tokens. Adding a track means searching the catalog, resolving the track URI, and calling the Add Items to Playlist endpoint with that URI. Reading your recent listening history and top tracks feeds the weekly mix. Every call uses a short lived access token minted from your refresh token, so the connection stays alive without you reauthorizing.
Imdad Codes' overview tours the Spotify Developer Dashboard and the authorization flow end to end, from creating an app to trading a code for the tokens the agent reuses on every call.
What you get
Once Spotify is connected, OpenClaw works your account the way you would, in small constant moves:
- Add a track to the right playlist by name, like "add that new Charli XCX single to my running list," and it creates the list if you do not have one yet.
- Trim a playlist that has gone stale, dropping the tracks that no longer fit.
- Build a playlist from a description, so "something mellow for working" comes back as an actual set of songs.
The one worth putting on a schedule is the weekly mix. Because the agent can read what you have been adding and playing lately through the user-read-recently-played and user-top-read scopes, it builds a set that is personal to you rather than a generic recommendation, shows you the tracklist first, and saves it once you approve. Over a few weeks that becomes your own discovery playlist, shaped by the conversations you have had with it rather than by a black box.
Before you start
This changed in early 2026. Spotify now requires the owner of a Development Mode app to have a Spotify Premium account, and it limits each developer to a single app with up to five authorized listeners. The five authorized users do not need Premium themselves, only the app owner does. For running your own playlists that is no constraint at all, since you are the one user who needs access, but if you are on a free Spotify plan the API will not work until you upgrade.
Spotify also tightened search pagination in Development Mode: the maximum limit per search request dropped from 50 to 10. If the agent needs to scan a large catalog result, it paginates with the offset parameter rather than fetching everything at once. The February 2026 migration guide lists every endpoint and field change if you are updating an older integration.
Extended Quota Mode removes the five user cap and supports a wider audience, but Spotify now accepts those applications only from organizations, not individuals. For a personal agent running your own account, Development Mode is the right fit.
Step 1: Create an app
Open the Spotify Developer Dashboard, log in, and click Create app. Give it a name and description, and set a redirect URI, which is the address Spotify sends you back to after you authorize. Something like http://127.0.0.1:8888/callback is fine for a personal setup, since you only need it for the one authorization step below.
Save the app, then open its Settings to find your Client ID and, behind the Reset or View option, your Client Secret. Copy both. Spotify's authorization guide covers the dashboard in more detail.
Step 2: Authorize once to get a refresh token
This is the only fiddly part, and you do it a single time. To act on your account, the agent needs a refresh token, which it gets from the Authorization Code flow. In short, you open Spotify's authorize URL in a browser with your client ID, your redirect URI, and the scopes the work needs, you approve the request, and Spotify hands back a code in the redirect URL. You then exchange that code at the token endpoint for an access token and a refresh token.
Request the scopes that match what you want the agent to do:
| Scope | What it enables |
|---|---|
playlist-modify-public, playlist-modify-private | build and edit playlists |
playlist-read-private | read your private playlists |
user-top-read, user-read-recently-played | let the weekly mix draw on your listening |
Spotify's scopes documentation explains what each one allows, and you should request only the ones the work needs. The token you keep is the refresh token, which is long lived. The access token it comes with only lasts an hour, but that does not matter, because the agent mints fresh ones from the refresh token as it goes.
Step 3: Add the three keys to Operator
In your Operator dashboard, open Environment and add three variables: SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, and SPOTIFY_REFRESH_TOKEN. Paste the values you gathered above. Each one is encrypted and shown to you only once, and the agent reads them by name when it needs to call the API, so the credentials never appear in a chat. With the client ID, secret, and refresh token in hand, it can keep itself authorized without you doing anything else.
Step 4: Connect a channel and try it
You talk to OpenClaw from Telegram or Discord, so connect one on the channels page if you have not. Then start handing it tracks and lists:
Add "Motion" by Calvin Harris to my gym playlist, and make the playlist if I don't have one yet.
Every Friday morning, build me a mix from what I've been playing this week, show me the tracklist, and save it once I say go.
The first is the everyday case, the kind of thing you would otherwise mean to do and forget. The second is the standing instruction that turns into a scheduled job, so a fresh playlist is waiting for you each week, and all you do is give it a thumbs up.
Good to know
Adding a track needs the song to exist in Spotify's catalog, so the rare regional gap or unreleased single it cannot find, it will say so rather than guess. Search returns at most ten results per request in Development Mode, so finding an obscure track may take a couple of queries with different spellings.
The five authorized user cap on a Development Mode app is plenty for your own account but means this is not the way to run playlists for a whole group of people. If your Premium subscription lapses, the app stops working until you resubscribe, per Spotify's current policy.
Because anything the agent saves is a real playlist on your account, keep the approval step on the weekly mix until you trust its taste, then let it run on its own.
Frequently asked questions
Do I need Spotify Premium to connect it to my agent?
+
Yes, for the developer app owner. Since early 2026 Spotify requires the owner of a Development Mode app to have a Premium account, and it limits each developer to one app with up to five authorized listeners. The authorized users themselves do not need Premium. For running your own playlists that is no constraint, but on a free Spotify plan the API will not work until you upgrade.
What credentials does the Spotify connection need?
+
Three: a client ID and client secret from an app you create in the Spotify Developer Dashboard, and a refresh token you get by authorizing once through the Authorization Code flow. Add them to Operator's Environment as SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET, and SPOTIFY_REFRESH_TOKEN. The refresh token is long lived, and the agent mints fresh hour long access tokens from it as it goes, so it stays connected on its own.
Which Spotify scopes should I authorize?
+
Match them to the work. playlist-modify-public and playlist-modify-private let the agent build and edit playlists, and playlist-read-private, user-top-read, and user-read-recently-played let the weekly mix draw on your listening. Spotify's scopes documentation explains what each one allows. Request only the ones you need.
Can the agent build a weekly playlist on its own?
+
Yes. Because it can read what you have been adding and playing, it builds a set personal to you rather than a generic recommendation, shows you the tracklist first, and saves it once you approve. Put it on a schedule and a fresh mix is waiting each week. Keep the approval step until you trust its taste, then let it run unattended. Anything it saves is a real playlist on your account.
Keep reading
Connect Pipedream to your agent and reach the apps you use
Link your own Pipedream account to Operator and your agent reaches Gmail, Slack, Notion, and the rest of your apps through one managed connection, with the OAuth sign in and token refresh handled for you.
May 31, 2026How to set up OpenClaw on Discord, step by step
Create a bot in the Discord Developer Portal, turn on the Message Content Intent, invite it with the right scopes, drop the token and application ID into your config, then approve the DM pairing code, including the intent toggle that leaves most bots online but silent.
May 31, 2026Set up your Discord channel on Operator
On Operator you connect Discord from the dashboard. You still make your own bot in Discord's Developer Portal, but there is no config file to edit and no terminal pairing. Paste the token, set the server policy, and your agent answers in your server.
May 31, 2026