Tokens
Create Personal Access Token
Create a new personal access token for authenticating API requests.
Request Body A JSON:API-compliant request with token attributes (name) and scopes as relationships.
Returns A 201 Created response with the newly created token details, including the token itself (token_id).
Note: The token (token_id) is returned only once during creation.
Errors - 400 Bad Request: Missing required fields or invalid scope. - 403 Forbidden: User lacks permission to create tokens.
post/tokens/
Request body
Example request
{
"data": {
"type": "tokens",
"attributes": {
"name": "My API Token"
},
"relationships": {
"scopes": {
"data": [
{
"type": "scopes",
"id": "osf.full_write"
}
]
}
}
}
}Response
Token successfully created.
Example response
{
"data": {
"id": "token123",
"type": "tokens",
"attributes": {
"name": "My API Token",
"token_id": "abc123def456"
},
"relationships": {
"scopes": {
"links": {
"related": "https://api.osf.io/v2/tokens/token123/scopes/"
}
}
}
}
}