Semestra

Account and API tokens

POST
/account/avatar

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

multipart/form-data
  1. body
file*File

Response Body

Successful Response

application/json
  1. response
id*Id
email*Email
display_name*Display Name
avatar_url*string|null
locale*string|null
has_password*Has Password
identities*array<>
created_at*Created At
Formatdate-time
Example Request
curl -X POST 'https://example.com/account/avatar' \  -F 'file=string'
Example Response
{  "id": "string",  "email": "string",  "display_name": "string",  "avatar_url": "string",  "locale": "string",  "has_password": true,  "identities": [    {      "provider": "google",      "email": "string",      "created_at": "2019-08-24T14:15:22Z"    }  ],  "created_at": "2019-08-24T14:15:22Z"}

Avatar Get

GET
/account/avatars/{user_id}/{version}

Public: the URL embeds a random version, so it is unguessable and cacheable forever.

Path Parameters

user_id*User Id
Match^[A-Za-z0-9_-]+$
version*Version
Match^[A-Za-z0-9_-]+$

Response Body

Successful Response

image/webp
Example Request
curl -X GET 'https://example.com/account/avatars/string/string'
Example Response
Empty
POST
/account/email/change-confirm

Finishes an email change started with account.email.change_start.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
code*Code

The 6-digit code sent to the new address

Match^\d{6}$

Response Body

Successful Response

application/json
  1. response
id*Id
email*Email
display_name*Display Name
avatar_url*string|null
locale*string|null
has_password*Has Password
identities*array<>
created_at*Created At
Formatdate-time
Example Request
curl -X POST 'https://example.com/account/email/change-confirm' \  -H 'Content-Type: application/json' \  -d '{  "code": "string"}'
Example Response
{  "id": "string",  "email": "string",  "display_name": "string",  "avatar_url": "string",  "locale": "string",  "has_password": true,  "identities": [    {      "provider": "google",      "email": "string",      "created_at": "2019-08-24T14:15:22Z"    }  ],  "created_at": "2019-08-24T14:15:22Z"}
POST
/account/email/change-start

Sends a verification code to the new address. Not available to agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
new_email*New Email

The new email address; a code is sent to it

password?|

Current password; needed unless the session signed in during the last 10 minutes

Response Body

Successful Response

application/json
  1. response
resend_in_seconds*Resend In Seconds
expires_in_seconds*Expires In Seconds
Example Request
curl -X POST 'https://example.com/account/email/change-start' \  -H 'Content-Type: application/json' \  -d '{  "new_email": "string"}'
Example Response
{  "resend_in_seconds": 0,  "expires_in_seconds": 0}
POST
/account/google/link

Links the Google account behind the given ID token. Not available to agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
id_token*Id Token

Google Identity Services ID token

Lengthlength <= 4096

Response Body

Successful Response

application/json
  1. response
id*Id
email*Email
display_name*Display Name
avatar_url*string|null
locale*string|null
has_password*Has Password
identities*array<>
created_at*Created At
Formatdate-time
Example Request
curl -X POST 'https://example.com/account/google/link' \  -H 'Content-Type: application/json' \  -d '{  "id_token": "string"}'
Example Response
{  "id": "string",  "email": "string",  "display_name": "string",  "avatar_url": "string",  "locale": "string",  "has_password": true,  "identities": [    {      "provider": "google",      "email": "string",      "created_at": "2019-08-24T14:15:22Z"    }  ],  "created_at": "2019-08-24T14:15:22Z"}
POST
/account/google/unlink

Removes the Google sign-in. Email code sign-in always remains available.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
id*Id
email*Email
display_name*Display Name
avatar_url*string|null
locale*string|null
has_password*Has Password
identities*array<>
created_at*Created At
Formatdate-time
Example Request
curl -X POST 'https://example.com/account/google/unlink'
Example Response
{  "id": "string",  "email": "string",  "display_name": "string",  "avatar_url": "string",  "locale": "string",  "has_password": true,  "identities": [    {      "provider": "google",      "email": "string",      "created_at": "2019-08-24T14:15:22Z"    }  ],  "created_at": "2019-08-24T14:15:22Z"}
POST
/account/password/change

Change the password (or set the first one). Signs out all other sessions.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
current_password?|

Current password; omit when the account has none yet

new_password*New Password

The new password

Length1 <= length <= 256

Response Body

Successful Response

application/json
  1. response
id*Id
email*Email
display_name*Display Name
avatar_url*string|null
locale*string|null
has_password*Has Password
identities*array<>
created_at*Created At
Formatdate-time
Example Request
curl -X POST 'https://example.com/account/password/change' \  -H 'Content-Type: application/json' \  -d '{  "new_password": "string"}'
Example Response
{  "id": "string",  "email": "string",  "display_name": "string",  "avatar_url": "string",  "locale": "string",  "has_password": true,  "identities": [    {      "provider": "google",      "email": "string",      "created_at": "2019-08-24T14:15:22Z"    }  ],  "created_at": "2019-08-24T14:15:22Z"}
GET
/account/me

Use when you need the user's name, email address or preferred language. Do not use to read academic data; use the academics, grading or schedule capabilities.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
id*Id
email*Email
display_name*Display Name
avatar_url*string|null
locale*string|null
has_password*Has Password
identities*array<>
created_at*Created At
Formatdate-time
Example Request
curl -X GET 'https://example.com/account/me'
Example Response
{  "id": "string",  "email": "string",  "display_name": "string",  "avatar_url": "string",  "locale": "string",  "has_password": true,  "identities": [    {      "provider": "google",      "email": "string",      "created_at": "2019-08-24T14:15:22Z"    }  ],  "created_at": "2019-08-24T14:15:22Z"}
PATCH
/account/profile

Change the signed-in user's profile. Not available to agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
display_name?|

New display name

avatar_url?|

HTTPS URL of the avatar image; send null to fall back to initials

Response Body

Successful Response

application/json
  1. response
id*Id
email*Email
display_name*Display Name
avatar_url*string|null
locale*string|null
has_password*Has Password
identities*array<>
created_at*Created At
Formatdate-time
Example Request
curl -X PATCH 'https://example.com/account/profile' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "id": "string",  "email": "string",  "display_name": "string",  "avatar_url": "string",  "locale": "string",  "has_password": true,  "identities": [    {      "provider": "google",      "email": "string",      "created_at": "2019-08-24T14:15:22Z"    }  ],  "created_at": "2019-08-24T14:15:22Z"}
GET
/account/sessions

Lists active sessions of the signed-in user. Not available to agents.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
items*array<>
Example Request
curl -X GET 'https://example.com/account/sessions'
Example Response
{  "items": [    {      "id": "string",      "kind": "web",      "user_agent": "string",      "ip": "string",      "created_at": "2019-08-24T14:15:22Z",      "last_used_at": "2019-08-24T14:15:22Z",      "expires_at": "2019-08-24T14:15:22Z",      "current": true    }  ]}

Sign out one device.

DELETE
/account/sessions/{session_id}

Revokes a session. Revoking the current session signs this browser out.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Path Parameters

session_id*Session Id

Id of the session to sign out

Response Body

Successful Response

application/json
  1. response
ok?Ok
Defaulttrue
Example Request
curl -X DELETE 'https://example.com/account/sessions/string'
Example Response
{  "ok": true}
POST
/account/sessions/revoke-others

Revokes every session except the current one.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
ok?Ok
Defaulttrue
Example Request
curl -X POST 'https://example.com/account/sessions/revoke-others'
Example Response
{  "ok": true}
GET
/account/tokens

Lists the user's non-revoked personal access tokens (never the secrets).

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Response Body

Successful Response

application/json
  1. response
items*array<>
Example Request
curl -X GET 'https://example.com/account/tokens'
Example Response
{  "items": [    {      "id": "string",      "name": "string",      "prefix": "string",      "scopes": [        "read"      ],      "created_at": "2019-08-24T14:15:22Z",      "last_used_at": "2019-08-24T14:15:22Z",      "expires_at": "2019-08-24T14:15:22Z"    }  ]}
POST
/account/tokens

Creates a token. The plaintext is returned once and cannot be retrieved again.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Request Body

application/json
  1. body
name*Name

A label, e.g. the client name

Length1 <= length <= 60
scopes?array<>

read allows read capabilities only; write also allows changes

Items1 <= items
expires_in_days?|

Lifetime in days; omit for no expiry

password?|

Current password; needed unless the session signed in during the last 10 minutes

Response Body

Successful Response

application/json
  1. response
id*Id
name*Name
prefix*Prefix
scopes*array<>
created_at*Created At
Formatdate-time
last_used_at*|null
expires_at*|null
token*Token

The plaintext token. Shown once, never stored.

Example Request
curl -X POST 'https://example.com/account/tokens' \  -H 'Content-Type: application/json' \  -d '{  "name": "string"}'
Example Response
{  "id": "string",  "name": "string",  "prefix": "string",  "scopes": [    "read"  ],  "created_at": "2019-08-24T14:15:22Z",  "last_used_at": "2019-08-24T14:15:22Z",  "expires_at": "2019-08-24T14:15:22Z",  "token": "string"}
DELETE
/account/tokens/{id}

Revokes the token immediately.

Authorization

cookiesemestra_session<token>

Set by the sign-in endpoints for the web app. Requests other than GET, HEAD and OPTIONS also need the X-Semestra-CSRF header set to the semestra_csrf cookie.

Path Parameters

id*Id

Id of the token to revoke

Response Body

Successful Response

application/json
  1. response
ok?Ok
Defaulttrue
Example Request
curl -X DELETE 'https://example.com/account/tokens/string'
Example Response
{  "ok": true}