POST /v1/projects/:projectId/social/reauth-url
Create a reconnect URL when a social account's tokens expire or get revoked upstream.
POST
/v1/projects/:projectId/social/reauth-urlPhase 1stable
- Auth
- Bearer
- Scope
- social:write
Create a fresh authorize URL for an account whose status has moved to reauth_required. The consent flow is identical to oauth-url — platform-domain page, your returnUrl, poll oauth-status — but on success the tokens bind back to the same socialAccountId instead of creating a new one.
Use this when you detect reauth_required in GET /v1/projects/:id/social-accounts, or when a scheduled post fails with CREDENTIAL_INVALID.
Path
projectIdstringrequiredProject owning the account.
Body
socialAccountIdstringrequiredAccount id returned by list-social-accounts.returnUrlstring (URL)requiredWhere Layers redirects after consent. Must be in the key's return_url_allowlist.scopesstring[]optionalOverride the default platform scope set. Max 32 entries, each ≤ 64 chars.
Example request
curl https://api.layers.com/v1/projects/prj_01HX9Y7K8M2P4RSTUV56789AB/social/reauth-url \
-H "Authorization: Bearer lp_live_01HX9Y6K7EJ4T2_4QZpN..." \
-H "Content-Type: application/json" \
-d '{
"socialAccountId": "sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A",
"returnUrl": "https://app.gicgrowth.com/reconnect/tiktok/return"
}'const { authorizeUrl, state } = await layers.social.createReauthUrl({
projectId: "prj_01HX9Y7K8M2P4RSTUV56789AB",
socialAccountId: "sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A",
returnUrl: "https://app.gicgrowth.com/reconnect/tiktok/return",
});
window.location.assign(authorizeUrl);result = layers.social.create_reauth_url(
project_id="prj_01HX9Y7K8M2P4RSTUV56789AB",
social_account_id="sa_01HXZ9P2M4N5KLM6TUV7WXYZ9A",
return_url="https://app.gicgrowth.com/reconnect/tiktok/return",
)Response
200Reauth URL created
{
"authorizeUrl": "https://www.tiktok.com/v2/auth/authorize?client_key=...&state=st_01HXZB...",
"state": "st_01HXZB4P9K2M3N4P5QRS6TUV7W",
"expiresAt": "2026-04-18T19:12:11Z"
}Once the user completes consent, the account's status returns to connected and the existing socialAccountId keeps its scheduled posts and metrics history.
Errors
| Status | Code | When |
|---|---|---|
| 400 | VALIDATION | returnUrl not an absolute URL, socialAccountId malformed, or platform of the account is not reauth-eligible (only TikTok and Instagram are reauthable today). |
| 401 | UNAUTHENTICATED | Missing or invalid key. |
| 403 | FORBIDDEN_SCOPE | Key lacks social:write. |
| 403 | RETURN_URL_NOT_ALLOWED | returnUrl not in the allowlist. |
| 404 | NOT_FOUND | Project or account not in your organization, or the account is already disconnected — use oauth-url to create a fresh binding. |
See also
GET /v1/projects/:id/social-accounts— watch forreauth_requiredGET /v1/social/oauth-status/:state— poll completion