Salesforce API: INVALID_SESSION_ID: Session expired or invalid
The access token or session ID is no longer accepted by Salesforce.
Exact message you may see
Session expired or invalid SalesforceSalesforce 401
Seen on:
Salesforce
Meaning
Sessions time out, tokens get revoked, or the request goes to the wrong instance (login vs my-domain).
Common causes
- Session timed out
- Token revoked or user logged out
- Wrong instance URL
- Connected app policy changed
⚡ Quick fix
- Refresh the OAuth token or log in again
- Use the
instance_urlreturned with the token - Check the connected app's session policy
Detailed fix by platform
cURL
curl -H "Authorization: Bearer $TOKEN" $INSTANCE_URL/services/data/v60.0/limits
How to diagnose
- Token — Expired?
- Instance — Right URL?
- Policy — Timeout setting?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Most viewed in API
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Did this fix work for you?
Report a correction or suggest an improvement
Last updated 2 Dec 2026