Users
Shorten User Subscription
If the user already has a premium access up to a certain time, this shortens/revokes his/her premium access. If the ends is less than or equal to the current time, it revokes the subscription and sets the end date to be the current time, else it just shortens the subscription.
PUT
/api/users/{handle}/shorten-subscription
Authorization*
curl --request PUT \
--url https://codecombat.com/api/users/{handle}/shorten-subscription \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '{
"ends": "<ends>"
}'
{
"_id": "string",
"email": "string",
"license": {
"active": "boolean",
"ends": "string"
},
"name": "string",
"oAuthIdentities": [
{
"id": "string",
"provider": "string"
}
],
"role": "string",
"slug": "string",
"stats": {
"concepts": "object",
"gamesCompleted": "number",
"playTime": "number"
},
"subscription": {
"active": "boolean",
"ends": "string"
}
}
url = `https://codecombat.com/api/users/${userID}/shorten-subscription`
json = { ends: new Date().toISOString() }
request.put({ url, json, auth }, (err, res) => {
console.log(res.body.subscription.active) // false
})
Authorizations
Authenticationheaderrequired
string
Basic authentication header of the form Basic <encoded-value>
, where <encoded-value>
is the base64-encoded string username:password
.
Path Parameters
handlerequired
string
The document's _id
or slug
.
Body
application/json
endsrequired
string
Response
200 - application/json
_id
string | null
email
string | null
license
object | null
name
string | null
oAuthIdentities
object[] | null
role
string | null
Usually either 'teacher' or 'student'
slug
string | null
stats
object | null
subscription
object | null
curl --request PUT \
--url https://codecombat.com/api/users/{handle}/shorten-subscription \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '{
"ends": "<ends>"
}'
{
"_id": "string",
"email": "string",
"license": {
"active": "boolean",
"ends": "string"
},
"name": "string",
"oAuthIdentities": [
{
"id": "string",
"provider": "string"
}
],
"role": "string",
"slug": "string",
"stats": {
"concepts": "object",
"gamesCompleted": "number",
"playTime": "number"
},
"subscription": {
"active": "boolean",
"ends": "string"
}
}