Skip to main content

Users

Admin APIs require authorization token with admin privileges. You check the following link to generate authorization token. You need to provide admin username and password to generate token with admin privileges.

Authentication

Admin Users API gives you access to create/edit users in the institute.

Create User

This endpoint creates a user.

HTTP Request

POST /api/v2.5/admin/users/

You can optionally add a batches field in the POST data with an array of batch names. The user will automatically get added to those batches during creation.

Except for username and password, all other fields are optional.

Query Parameters

ParameterTypeDescription
auto_generate_password=truestringAutomatically generates a password. The user will receive login credentials via email and SMS.
notify_credential=truestringSends email and SMS notifications to the user with their login credentials.

Note: Password field is not required if the auto_generate_password=true query parameter is applied.

Fields

NameTypeDescription
usernamestringUsername of the user
first_namestringFirst name of the user
last_namestringLast of the user
emailstringEmail of the user
birth_datedatestringBirth date of user. Should be in DD/MM/YYYY format
address1stringAddress of the user
address2stringAddress of the user
citystringCity of the user
zipstringPincode of the user
statestringState of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phonestringPhone of the user
batcheslistBatches of the user
expiresdatestringExpiry date of the batches subscription. Format yyyy-mm-dd. After which the user will be removed form the batch
custom_fieldsjsonA dictionary containing custom field name and the response to be recorded for the user. The custom field name is case-insensitive.
curl --request POST \
--url http://demo.testpress.in/api/v2.5/admin/users/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"username": "lorem", "password": "ipsum1$", "first_name": "John", "last_name": "Appleseed", "email": "test@example.com", "birth_date": "03/07/2016", "state": "IN-TN", "batches": ["Test Batch", "UPSC Morning Batch"],"expires":"2023-01-13", "custom_fields": {"Graduation University": "Delhi University", "Graduation Year": 2020}}'

Response

{
"id": 1892,
"url": "http://demo.testpress.in/api/v2.5/admin/users/1892/",
"username": "lorem",
"first_name": "John",
"last_name": "Appleseed",
"display_name": "John Appleseed",
"email": "test@example.com",
"photo": null,
"birth_date": "03/07/2016",
"address1": "",
"address2": "",
"city": "",
"zip": "",
"state": "Tamil Nadu",
"state_code": "IN-TN",
"phone": "",
"batches_url": "http://demo.testpress.in/api/v2.5/admin/users/1892/batches/",
"custom_fields": {
"Graduation University": "Delhi University",
"Graduation Year": 2020
}
}

View All Users

This endpoint allows you to get all users.

HTTP Request

GET /api/v2.5/admin/users/

Query Parameters

ParameterTypeDescription
qstringFilters by Username or Email

Examples:

/api/v2.5/admin/users/?q=john

/api/v2.5/admin/users/?q=test@gmail.com

Fields

NameTypeDescription
usernamestringUsername of the user
first_namestringFirst name of the user
last_namestringLast of the user
display_namestringName of the user to be displayed
emailstringEmail of the user
photostringOriginal image of the user as uploaded
birth_datedatestringBirth date of user. Should be in DD/MM/YYYY format
genderstring(Read only) Human readable gender of user. Can be "Male", "Female" or "Transgender"
address1stringAddress of the user
address2stringAddress of the user
citystringCity of the user
zipstringPincode of the user
statestringState of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phonestringPhone of the user
curl --request GET \
--url http://demo.testpress.in/api/v2.5/admin/users/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"username": "admin15", "password": "demouser", "first_name": "Cool", "last_name": "dude", "email": "cool@dude.com", "birth_date": "03/07/2016", "state": "IN-TN"\n}'

Response

{
"count": 756,
"next": "https://demo.testpress.in/api/v2.5/admin/users/?page=2",
"previous": null,
"per_page": 20,
"results": [

{
"id": 1889,
"url": "http://demo.testpress.in/api/v2.5/admin/users/",
"username": "lorem",
"first_name": "John",
"last_name": "Appleseed",
"display_name": "John Appleseed",
"email": "test@example.com",
"photo": null,
"birth_date": "03/07/2016",
"address1": "",
"address2": "",
"city": "",
"zip": "",
"state": "IN-TN",
"phone": "",
"batches_url": "http://demo.testpress.in/api/v2.5/admin/users/1/batches/"
},

{
"id": 1890,
"url": "http://demo.testpress.in/api/v2.5/admin/users/",
"username": "lorem2",
"first_name": "John2",
"last_name": "Appleseed",
"display_name": "John Appleseed",
"email": "test3@example.com",
"photo": null,
"birth_date": "23/07/2000",
"address1": "",
"address2": "",
"city": "",
"zip": "",
"state": "IN-TN",
"phone": "",
"batches_url": "http://demo.testpress.in/api/v2.5/admin/users/2/batches/"
}

]

}


View User

This endpoint allows you to view details of a particular user.

HTTP Request

GET /api/v2.5/admin/users/<:id>

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

Fields

NameTypeDescription
usernamestringUsername of the user
first_namestringFirst name of the user
last_namestringLast of the user
display_namestringName of the user to be displayed
emailstringEmail of the user
photostringOriginal image of the user as uploaded
birth_datedatestringBirth date of user. Should be in DD/MM/YYYY format
genderstring(Read only) Human readable gender of user. Can be "Male", "Female" or "Transgender"
address1stringAddress of the user
address2stringAddress of the user
citystringCity of the user
zipstringPincode of the user
statestringState of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phonestringPhone of the user
curl --request GET \
--url http://demo.testpress.in/api/v2.5/admin/users/1889/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"username": "admin15", "password": "demouser", "first_name": "Cool", "last_name": "dude", "email": "cool@dude.com", "birth_date": "03/07/2016", "state": "IN-TN"\n}'

Response

{
"id": 1889,
"url": "http://demo.testpress.in/api/v2.5/admin/users/1889/",
"username": "lorem",
"first_name": "John",
"last_name": "Appleseed",
"display_name": "John Appleseed",
"email": "test@example.com",
"photo": null,
"birth_date": "03/07/2016",
"address1": "",
"address2": "",
"city": "",
"zip": "",
"state": "IN-TN",
"phone": "",
"batches_url": "http://demo.testpress.in/api/v2.5/admin/users/1889/batches/"
}

Update User

This endpoint allows you to update details of a particular user.

HTTP Request

PUT /api/v2.5/admin/users/<:id>

URL Parameters

ParametterDescription
idUnique Id of the user to update

Fields

NameTypeDescription
usernamestringUsername of the user
passwordstringPassword to update the user
first_namestringFirst name of the user
last_namestringLast of the user
display_namestringName of the user to be displayed
emailstringEmail of the user
photostringOriginal image of the user as uploaded
birth_datedatestringBirth date of user. Should be in DD/MM/YYYY format
genderstring(Read only) Human readable gender of user. Can be "Male", "Female" or "Transgender"
address1stringAddress of the user
address2stringAddress of the user
citystringCity of the user
zipstringPincode of the user
statestringState of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phonestringPhone of the user
is_activebooleanUsed to activate/deactivate the user. Accepts "true"/"false".
custom_fieldsjsonA dictionary containing custom field name and the response to be recorded for the user. The custom field name is case-insensitive.

Read Only Fields

password_hash, gender, state, large_image, medium_image, medium_small_image, small_image, xsmall_image, mini_image, created, modified

Write Only Fields

password

url --request PUT \
--url http://demo.testpress.in/api/v2.5/admin/users/2120/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--header 'postman-token: 5bdb17f6-db4d-c72e-a30f-c1776f0d8384' \
--data '{\n "password": "welcome"\n}'

Response

{
"id": 2120,
"username": "goodboy",
"password_hash": "pbkdf2_sha256$12000$zaz1v370q51a$ipNrjQCWNOAmdFsHWPHHZ1i1+5hxF5LxHZ+VfFZ9mrM=",
"email": "",
"first_name": "",
"last_name": "",
"display_name": "goodboy",
"photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/png/3a6be029faea4c41915291da8778c36d.png",
"birth_date": null,
"address1": "",
"address2": "",
"city": "",
"zip": "",
"state": "",
"state_code": "",
"phone": "",
"batches_url": "http://demo.testpress.in/api/v2.5/admin/users/2120/batches/",
"url": "http://demo.testpress.in/api/v2.5/admin/users/2120/",
"created": "2017-08-03T18:25:45.949568Z",
"modified": "2017-08-03T18:29:24.712464Z",
"custom_fields": {
"Graduation University": "Delhi University",
"Graduation Year": 2020
}
}

Delete User

This endpoint allows you to delete particular user. Please be aware this will delete all the data related to the user. The operation is ir reversible

HTTP Request

DELETE /api/v2.2/admin/users/<:id>

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

View User By Email

This endpoint allows you to view details of a particular user by email address

HTTP Request

GET /api/v2.5/admin/users/?email=<:email_id>

URL Parameters

ParametterDescription
idEmail Address of the user

Fields

NameTypeDescription
usernamestringUsername of the user
first_namestringFirst name of the user
last_namestringLast of the user
display_namestringName of the user to be displayed
emailstringEmail of the user
photostringOriginal image of the user as uploaded
large_imagestringProfile image with size 256x256
medium_imagestringProfile image with size 128x128
small_imagestringProfile image with size 48x48
xsmall_imagestringProfile image with size 32x32
mini_imagestringProfile image with size 24x24
birth_datedatestringBirth date of user. Should be in DD/MM/YYYY format
gender_codestringGender of user. Can be "male", "female" or "trans"
genderstring(Read only) Human readable gender of user. Can be "Male", "Female" or "Transgender"
address1stringAddress of the user
address2stringAddress of the user
citystringCity of the user
zipstringPincode of the user
state_codestringState of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)
phonestringPhone of the user
batchesarrayBatches to which user has access
curl -X GET -H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzODY4NTV9.5w4InsvTPtQGgj4L1myQGc1qxw7IvNEpa3BtVfQOtxE" -H "Cache-Control: no-cache" -H "Postman-Token: c8cbe2a1-76d0-da3a-1bbb-38cd3f61f215" "http://demo.testpress.in//api/v2.5/admin/users/?email=bharathwaaj.s@gmail.com"

Response

{
"count": 1,
"next": null,
"previous": null,
"per_page": 20,
"results": [
{
"id": 36,
"url": "http://demo.testpress.in/api/v2.2/admin/users/36/",
"username": "bharath",
"first_name": "Bharath Kumar",
"last_name": "S",
"display_name": "Bharath Kumar S",
"email": "bharathwaaj.s@gmail.com",
"photo": "https://s3-ap-southeast-1.amazonaws.com/media.testpress.in/i/cb88287098924bd6ae615ca4aa71eab5.png",
"large_image": "",
"medium_image": "",
"small_image": "",
"x_small_image": "",
"mini_image": "",
"birth_date": "17/08/1987",
"gender_code": "male",
"gender": "Male",
"address1": "257 A Timber Mill Road",
"address2": "4th Cross, New Thippasandra",
"city": "Bangalore",
"zip": "560075",
"state": "",
"state_code": "",
"phone": "9787231006",
"batches": [
{
"id": 26,
"name": "UPSC Evening Batch",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/26/"
},
{
"id": 25,
"name": "IBPS Online Batch",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/25/"
},
{
"id": 24,
"name": "NEET Morning Batch",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/24/"
},
{
"id": 23,
"name": "UPSC Morning Batch",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/23/"
},
{
"id": 22,
"name": "IBPS Morning Batch",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/22/"
},
{
"id": 21,
"name": "st std A",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/21/"
},
{
"id": 20,
"name": "OHC 2013",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/20/"
},
{
"id": 19,
"name": "POZITIVE ONLINE TEST SERIES",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/19/"
},
{
"id": 18,
"name": "Unique UPSC Batch",
"url": "http://demo.testpress.in/api/v2.2/admin/batches/18/"
}
],
"batches_url": "http://demo.testpress.in/api/v2.2/admin/users/36/batches/"
}
]
}

View Batches

This endpoint allows you to view batches of a particular user.

HTTP Request

GET /api/v2.5/admin/users/<id>/batches/

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

Response Fields

NameTypeDescription
idstringId of the batch
urlstringUnique endpoint of that batch
namestringName of the batch
curl --request GET \
--url http://demo.testpress.in/api/v2.5/admin/users/1892/batches/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json'

Response

{
"count": 2,
"next": null,
"previous": null,
"per_page": 20,
"results": [
{
"id": 29,
"name": "Test Batch",
},
{
"id": 23,
"name": "UPSC Morning Batch",
}
]
}

Add Batches

This endpoint allows you to add users to batches

HTTP Request

POST /api/v2.5/admin/users/<id>/batches/

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

Response Fields

NameTypeDescription
idstringId of the batch
urlstringUnique endpoint of that batch
namestringName of the batch
curl --request POST \
--url http://demo.testpress.in/api/v2.5/admin/users/1892/batches/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"batches": [24, 22]}'

Response

[
{
"id": 29,
"name": "Test Batch",
},
{
"id": 24,
"name": "NEET Morning Batch",
},
{
"id": 23,
"name": "UPSC Morning Batch",
},
{
"id": 22,
"name": "IBPS Morning Batch",
}
]

Remove Batches

This endpoint allows you to add users to batches

HTTP Request

DELETE /api/v2.5/admin/users/<id>/batches/

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

POST data

ParametterDescription
batchesList of batch ids
curl --request DELETE \
--url http://demo.testpress.in/api/v2.5/admin/users/1892/batches/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"batches": [24, 22]}'

Response

The above command on success will return 204 NO CONTENT

Add Courses

This endpoint allows you to add courses to a user

HTTP Request

POST /api/v2.5/admin/users/<id>/courses/

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

POST data

ParametterDescription
coursesList of course ids
curl --request POST \
--url http://lmsdemo.testpress.in/api/v2.5/admin/users/1892/courses/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"courses": [278, 279]}'

Response

{
"count": 5,
"next": null,
"previous": null,
"per_page": 20,
"results": [
{
"id": 278,
"title": "Master of Business Administration",
"slug": "master-of-business-administration",
"description": "",
"image": "https://static.testpress.in/institute/lmsdemo/custom_icons/0351510ee9254487a6d393f966d0f2f3.jpg",
"is_public": true,
"created": "2020-12-09T09:39:53.863767Z",
"modified": "2020-12-14T12:58:36.148936Z",
"enable_progressive_lock": false,
"order": 8,
"url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/278/",
"batches_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/278/batches/",
"chapters_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/278/chapters/",
"contents_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/278/contents/"
},
{
"id": 279,
"title": "Language training",
"slug": "language-training",
"description": "",
"image": "https://static.testpress.in/institute/lmsdemo/custom_icons/e293fdefcfdc46a8892ca12a0bdbb7cc.jpg",
"is_public": true,
"created": "2020-12-09T09:56:31.350026Z",
"modified": "2020-12-12T10:17:05.427842Z",
"enable_progressive_lock": false,
"order": 9,
"url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/279/",
"batches_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/279/batches/",
"chapters_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/279/chapters/",
"contents_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/279/contents/"
},
{
"id": 280,
"title": "Entrance Coaching",
"slug": "entrance-coaching",
"description": "",
"image": "https://static.testpress.in/institute/lmsdemo/custom_icons/421d84a1778a4c55a6b6ceaac1e540e7.jfif",
"is_public": true,
"created": "2020-12-09T09:59:48.392077Z",
"modified": "2020-12-12T10:17:05.427842Z",
"enable_progressive_lock": false,
"order": 10,
"url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/280/",
"batches_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/280/batches/",
"chapters_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/280/chapters/",
"contents_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/280/contents/"
},
{
"id": 281,
"title": "Skill Development Training",
"slug": "skill-development-training",
"description": "",
"image": "https://static.testpress.in/institute/lmsdemo/custom_icons/a3687fd5094042ddb8ab043eecf1d2d2.jpg",
"is_public": true,
"created": "2020-12-09T10:00:58.923825Z",
"modified": "2020-12-12T10:17:05.427842Z",
"enable_progressive_lock": false,
"order": 11,
"url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/281/",
"batches_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/281/batches/",
"chapters_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/281/chapters/",
"contents_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/281/contents/"
},
{
"id": 283,
"title": "TD",
"slug": "td",
"description": "",
"image": "https://static.testpress.in/institute/lmsdemo/custom_icons/26759ff073e34454945f5ea867e7afee.png",
"is_public": false,
"created": "2020-12-11T10:37:20.205025Z",
"modified": "2020-12-13T17:15:37.681858Z",
"enable_progressive_lock": false,
"order": 7,
"url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/283/",
"batches_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/283/batches/",
"chapters_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/283/chapters/",
"contents_url": "https://lmsdemo.testpress.in/api/v2.5/admin/courses/283/contents/"
}
]
}

Remove Courses

This endpoint allows you to remove courses from a user

HTTP Request

DELETE /api/v2.5/admin/users/<id>/courses/

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

POST data

ParametterDescription
coursesList of course ids that needs to be removed user
curl --request DELETE \
--url http://lmsdemo.testpress.in/api/v2.5/admin/users/1892/courses/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"courses": [24, 22]}'

Response

The above command on success will return 204 NO CONTENT

View User Subscriptions

This endpoint allows you to view subscriptions of a particular user.

HTTP Request

GET /api/v2.5/admin/users/<id>/subscriptions/

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

Response Fields

NameTypeDescription
idstringId of the user subsciption
batch.idstringId of the batch
batch.urlstringUnique endpoint of that batch
batch.namestringName of the batch
expiresdatestringExpiry date of the batches subscription. Format yyyy-mm-dd. After which the user will be removed form the batch
curl --request GET \
--url http://demo.testpress.in/api/v2.5/admin/users/1892/subscriptions/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json'

Response

{
"count": 2,
"next": null,
"previous": null,
"per_page": 20,
"results": [
{
"id":70,
"batch": {
"id": 85,
"name": "Test Batch",
"url": "http://demo.testbench.in:8000/api/v2.5/admin/batches/85/",
"created": "2023-01-12T11:06:19.298526+05:30",
"modified": "2023-01-12T11:06:19.298526+05:30",
"is_local": false
},
"expires": "2023-01-13"
},
{
"id":33,
"batch": {
"id": 86,
"name": "UPSC Batch",
"url": "http://demo.testbench.in:8000/api/v2.5/admin/batches/86/",
"created": "2023-01-12T11:07:16.060993+05:30",
"modified": "2023-01-12T11:07:16.060993+05:30",
"is_local": false
},
"expires": "2023-01-13"
}
]
}

Add User Subscriptions

This endpoint allows you to add users to a subscription

HTTP Request

POST /api/v2.5/admin/users/<id>/subscriptions/

URL Parameters

ParametterDescription
idUnique Id of the user to retrieve

Fields

NameTypeDescription
batcheslistBatch ids
expiresdatestringExpiry date of the batches subscription. Format yyyy-mm-dd. After which the user will be removed form the batch
curl --request POST \
--url http://demo.testpress.in/api/v2.5/admin/users/1892/subscriptions/ \
--header 'authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84' \
--header 'cache-control: no-cache' \
--header 'content-type: application/json' \
--data '{"batches": [24, 22],"expires":"2023-01-13"}'

Response

[
{
"id": 33,
"batch": {
"id": 85,
"name": "Test Batch",
"url": "http://demo.testbench.in:8000/api/v2.5/admin/batches/85/",
},
"expires": "2023-01-13"
},
{
"id": 34,
"batch": {
"id": 86,
"name": "UPSC Batch",
"url": "http://demo.testbench.in:8000/api/v2.5/admin/batches/86/",
},
"expires": "2023-01-13"
}
]