Skip to main content

API Key

Base URL: https://api-sls.platzi.com/production-sls-business-domains

Endpoints under /v2/api-key/auth/ let you validate an API key and generate single-use SSO magic links for users that already exist in your company.

Both endpoints self-authenticate via the x-platzi-company-api-key header


GET /v2/api-key/auth/validation/ - Validate API Key

Validates the API key provided in the x-platzi-company-api-key header and returns the claims associated with it.

Use this endpoint to verify that a key is active and to read the company_id, organization_id, role, and granted scope before calling other endpoints.

Request

GET /v2/api-key/auth/validation/
x-platzi-company-api-key: platzi-xxxxxxxxxxxx.xxxxxxxx...
User-Agent: <your-user-agent>

Success Response (200)

{
"data": {
"company_id": "123",
"organization_id": "10",
"user_id": "4567",
"user_profile_id": "8910",
"user_role": "company_admin",
"scope": "reports.read,sso.magiclink"
}
}

Response Fields

FieldDescription
company_idCompany the key belongs to
organization_idOrganization associated with the key
user_idUser ID tied to the key
user_profile_idUser profile ID tied to the key
user_roleRole granted to the key
scopeComma-separated list of scopes granted to the key

Error Response (401)

{
"errors": [
{ "error_code": "unauthorized_user", "message": "Unauthorized user" }
]
}

Returned when the header is missing, malformed, or the key has expired.


Generates a single-use magic link that logs a B2B user into Platzi without a password. Requires the API key to have the sso.magiclink scope.

The user identifier (email, username, or phone number) must be encrypted with the api_secret tied to your API key, using Fernet symmetric encryption. The api_secret is provided by Platzi organizers when the key is issued.

Request

GET /v2/api-key/auth/magic-link/?email=<encrypted-value>&only_active=true&next_url=/browse
x-platzi-company-api-key: platzi-xxxxxxxxxxxx.xxxxxxxx...
User-Agent: <your-user-agent>

Query Parameters

ParameterTypeRequiredDescription
emailstringone-ofFernet-encrypted email. Exactly one identifier must be provided.
usernamestringone-ofFernet-encrypted username. Only accepted when the company setting allows.
phone_numberstringone-ofFernet-encrypted phone number. Only accepted when the company setting allows.
only_activestringnotrue/false (default false). If true, reject users that are not active.
next_urlstringnoRelative path to redirect to after login (e.g. /browse).

Identifier Rules

  • Exactly one of email, username, or phone_number must be supplied. Providing zero or more than one returns 400.
  • username and phone_number are only accepted when the company has that setting enabled. Ask Platzi organizers if you need it.
  • The identifier value must be encrypted with your api_secret (Fernet) before being sent as a query parameter.

Active User Rule (only_active=true)

When only_active=true, the user is accepted only if they are currently active in the company — i.e. fully active, or still in the invitation phase with at least one reserved/active license. Otherwise the request fails with user_not_active.

Success Response (200)

{
"data": {
"url": "https://platzi.com/sso/magic-link/verify/?token=abc123..."
}
}

The returned url is single-use and short-lived. Redirect the end user to it to complete the SSO flow.

Error Response

{
"errors": [
{
"error_code": "user_not_found",
"message": "User not found in company"
}
]
}

Error Codes

CodeStatusDescription
missing_api_key401x-platzi-company-api-key header is missing
invalid_api_key401API key is invalid or expired
unauthorized_scope401API key does not include the sso.magiclink scope
invalid_identifier400Zero or more than one identifier was provided
identifier_not_allowed400Company does not allow username / phone_number identifiers
decryption_failed400Identifier could not be decrypted with the key's api_secret
user_not_found400Identifier does not match a user in the company
user_not_active400only_active=true was set and the user is not active in the company
magic_link_generation_failed500Internal error while generating the magic link

Generates one SSO magic-link token and returns it alongside the classes inside a given course. Every class entry carries its own deep link, built from the single token plus a next= query parameter that points to that specific class.

Requires the API key to have the sso.magiclink scope.

Request

GET /v2/api-key/auth/magic-link/course/?email=<encrypted-value>&course_id=1234
x-platzi-company-api-key: platzi-xxxxxxxxxxxx.xxxxxxxx...
User-Agent: <your-user-agent>

Query Parameters

ParameterTypeRequiredDescription
emailstringone-ofFernet-encrypted email. Exactly one identifier must be provided.
usernamestringone-ofFernet-encrypted username. Only accepted when the company setting allows.
phone_numberstringone-ofFernet-encrypted phone number. Only accepted when the company setting allows.
course_idintegeryesNumeric Core course ID. Must be a positive integer.

Identifier and encryption rules are identical to /v2/api-key/auth/magic-link/.

Success Response (200)

{
"data": {
"magic_link_base": "https://platzi.com/sso/magic-link/verify/?token=abc123...",
"course_id": 1234,
"classes": [
{
"material_id": 88,
"name": "Introducción",
"viewed": false,
"magic_link": "https://platzi.com/sso/magic-link/verify/?token=abc123...&next=%2Fcursos%2Freact%2Fintroduccion%2F"
}
]
}
}

Response Fields

FieldDescription
magic_link_baseThe single magic-link URL (no class-specific next). One-time use.
course_idEchoed back from the request.
classesArray of classes (materials) inside the course, in pedagogic order.
material_idNumeric class (material) ID.
nameClass name as it appears in Platzi.
viewedWhether the user has viewed this class.
magic_linkSingle-use SSO URL that lands the user on this class after login.

Notes

  • The shared magic_link_base and every per-class magic_link redeem the same one-time token; the next query parameter is the only difference. Once the token is consumed all class links stop working.
  • viewed reflects per-material viewed state.
  • This endpoint does not verify that the user has access to the course (license / catalog / private course rules). Validate access upstream if your flow requires it.
  • An existing course with no published classes returns 200 with classes: [].

Error Codes

CodeStatusDescription
missing_api_key401x-platzi-company-api-key header is missing
invalid_api_key401API key is invalid or expired
unauthorized_scope401API key does not include the sso.magiclink scope
invalid_identifier400Zero or more than one identifier was provided
invalid_course_id400course_id is missing, non-numeric, or non-positive
identifier_not_allowed400Company does not allow username / phone_number identifiers
decryption_failed400Identifier could not be decrypted with the key's api_secret
user_not_found400Identifier does not match a user in the company
course_not_found404course_id does not match any existing course
magic_link_generation_failed500Internal error while generating the magic link