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, generate single-use SSO magic links for users that already exist in your company, and read the structure of a course and the classes your users have viewed.

All 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.

Users Invited Moments Ago​

A link can be requested right after inviting a user, while their account is still being set up. The response is the same 200 with a url. If the user opens it before the setup finishes, they see a short "preparing your access" page that signs them in automatically as soon as their account is ready.

For these users only_active=true is checked when the link is opened rather than when it is requested: if the user is not active by then, they are sent to the login page instead of being signed in.

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
user_not_ready409Rare. User was just invited and a link cannot be issued yet; retry shortly
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. For a user invited moments ago whose account is still being set up, every class is viewed: false, and the links behave as described in Users Invited Moments Ago.
  • 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: [] and "code": -58010 (see Result Codes).

Result Codes​

Some outcomes also carry a numeric code at the top level of the body, next to data or errors, so you can map each one to the message you show your user. The rest of the body is unchanged, and responses not listed here have no code field.

codeStatusWhenSuggested message to the user
-58010200The magic link was generated but the course has no classes yetThere is no content available in this course yet
-58011404course_id does not match any existing courseThe course could not be found
-58012500The magic link could not be generatedThere was a problem validating your access
{
"data": {
"magic_link_base": "https://platzi.com/sso/magic-link/verify/?token=abc123...",
"course_id": 1234,
"classes": []
},
"code": -58010
}
{
"errors": [
{
"message": "Failed to generate magic link",
"error_code": "magic_link_generation_failed"
}
],
"code": -58012
}

A request can also fail before it reaches this endpoint (for example, a network timeout or an invalid API key rejected at the edge). Those responses have no code; treat any non-2xx response without a code as -58012.

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. code: -58011
user_not_ready409Rare. User was just invited and a link cannot be issued yet; retry shortly
magic_link_generation_failed500Internal error while generating the magic link. code: -58012

GET /v2/api-key/auth/courses/{course_id}/syllabus/ - Course Structure​

Returns the modules and classes of a course, in the order learners take them, plus the path of the course exam when the course has one. Use it to mirror a course in your own platform (for example, one section per module and one activity per class) without generating a magic link.

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

Request​

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

Path Parameters​

ParameterTypeRequiredDescription
course_idintegeryesCourse ID. Must be a positive integer.

Success Response (200)​

{
"data": {
"course_id": 1234,
"title": "Curso de React.js",
"slug": "react",
"path": "/cursos/react/",
"classes_total": 3,
"modules": [
{
"module_id": 10,
"title": "Introducción",
"position": 1,
"classes": [
{
"material_id": 88,
"name": "Bienvenida",
"type": "video",
"duration_seconds": 360,
"position": 1,
"path": "/cursos/react/bienvenida/"
},
{
"material_id": 89,
"name": "Qué vas a construir",
"type": "lecture",
"duration_seconds": 0,
"position": 2,
"path": "/cursos/react/que-vas-a-construir/"
}
]
},
{
"module_id": 12,
"title": "Hooks",
"position": 2,
"classes": [
{
"material_id": 90,
"name": "useState",
"type": "video",
"duration_seconds": 600,
"position": 3,
"path": "/cursos/react/usestate/"
}
]
}
],
"exam": { "path": "/evaluacion/555/" }
}
}

Response Fields​

FieldDescription
course_idEchoed back from the request.
titleCourse title. null when it could not be read; the structure is still complete.
slug / pathCourse slug and its path on platzi.com. null when the course has no classes.
classes_totalNumber of classes across all modules.
modules[].module_idModule ID. Stable while the module exists.
modules[].titleModule title.
modules[].positionModule order, starting at 1.
classes[].material_idClass ID. The same ID viewed and /progress/ refer to.
classes[].nameClass name.
classes[].typeKind of class: video, lecture, audio, file, iframe or simulation_class. Treat unknown values as video.
classes[].duration_secondsDuration in seconds. 0 when the class has no duration (for example, readings).
classes[].positionOrder of the class across the whole course, starting at 1.
classes[].pathPath of the class on platzi.com. Pass it as next_url to /auth/magic-link/ to land the user on it.
exam{ "path": ... } when the course has a certification exam, otherwise null.

Notes​

  • Modules without classes are left out.
  • A class that disappears from the response was removed from the course. Keep the learner's completion on your side; do not treat the removal as lost progress.
  • This endpoint does not check that the course is in your company's catalog. Use GET /v3/lp-builder/{company_id}/courses/ to list the courses your users can take.

Result Codes​

Uses the same numbering as /auth/magic-link/course/.

codeStatusWhen
-58010200The course exists but has no classes yet (modules: [])
-58011404course_id does not match a course in your company's catalog or Platzi's public catalog
-58013503The course could not be read right now. Retry later; do not treat it as a removed course

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_course_id400course_id is non-numeric or non-positive
course_not_found404course_id does not match a course in your company's catalog or Platzi's public catalog. code: -58011
course_unavailable503Temporary failure reading the course. code: -58013. Has a Retry-After header
course_content_failed500Internal error

GET /v2/api-key/auth/courses/{course_id}/progress/ - Viewed Classes per User​

Returns, for up to 25 users at a time, which classes of a course each one has viewed. Use it to keep class completion in sync without generating a magic link per user.

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

Request​

GET /v2/api-key/auth/courses/1234/progress/?user_ids=501,502,503
x-platzi-company-api-key: platzi-xxxxxxxxxxxx.xxxxxxxx...
User-Agent: <your-user-agent>

Query Parameters​

ParameterTypeRequiredDescription
user_idsstringyes1 to 25 distinct Platzi user IDs, comma separated. The user_id of GET /v3/users/{company_id}.

Success Response (200)​

{
"data": {
"course_id": 1234,
"classes_total": 3,
"users": [
{ "user_id": 501, "available": true, "viewed_material_ids": [88, 90] },
{ "user_id": 503, "available": false, "viewed_material_ids": [] }
]
}
}

Response Fields​

FieldDescription
course_idEchoed back from the request.
classes_totalNumber of classes the course has now.
users[].user_idOne entry per requested user that belongs to your company, in request order.
users[].availablefalse when this user's progress could not be read right now. Keep what you already have and retry later.
users[].viewed_material_idsIDs of the classes the user has viewed, limited to the classes the course has now. Same IDs as /syllabus/.

Notes​

  • User IDs that are not current members of your company (including former members) are left out of users. They never return data and never fail the request.
  • available: false with an empty list does not mean "nothing viewed". Only available: true entries are authoritative.
  • An empty viewed_material_ids with available: true means the user has not viewed any class yet.

Result Codes​

Same as /syllabus/: -58010 (course with no classes, 200), -58011 (course not found, 404) and -58013 (course temporarily unavailable, 503).

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_course_id400course_id is non-numeric or non-positive
invalid_user_ids400user_ids is missing, has more than 25 IDs, repeats an ID or contains a non-positive or non-numeric value
course_not_found404course_id does not match a course in your company's catalog or Platzi's public catalog. code: -58011
course_unavailable503Temporary failure reading the course. code: -58013. Has a Retry-After header
course_content_failed500Internal error