Users

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.

Fields

Name

Type

Description

username

string

Username of the user

first_name

string

First name of the user

last_name

string

Last name of the user

email

string

Email of the user

birth_date

datestring

Birth date of user. Should be in DD/MM/YYYY format

address1

string

Address of user

address2

string

Address of user

city

string

City of user

zip

string

Pincode of user

state

string

State of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)

phone

string

Phone of user

batches

string

Pass as array of batch name strings.

cURL
Ruby
Python
C#
PHP
Java
NodeJS
Go
cURL
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": "[email protected]", "birth_date": "03/07/2016", "state": "IN-TN", "batches": ["Test Batch", "UPSC Morning Batch"]}'

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Ruby
require 'uri'
require 'net/http'
url = URI("http://demo.testpress.in/api/v2.5/admin/users/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"lorem\",\n \"password\": \"ipsum1$\",\n \"first_name\": \"John\",\n \"last_name\": \"Appleseed\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\",\n \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}"
response = http.request(request)
puts response.read_body

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Python
import requests
url = "http://demo.testpress.in/api/v2.5/admin/users/"
payload = "{\n \"username\": \"lorem\",\n \"password\": \"ipsum1$\",\n \"first_name\": \"John\",\n \"last_name\": \"Appleseed\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\",\n \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}"
headers = {
'content-type': "application/json",
'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
'cache-control': "no-cache"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
C#
var client = new RestClient("http://demo.testpress.in/api/v2.5/admin/users/");
var request = new RestRequest(Method.POST);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"username\": \"lorem\",\n \"password\": \"ipsum1$\",\n \"first_name\": \"John\",\n \"last_name\": \"Appleseed\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\",\n \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
PHP
<?php
$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.5/admin/users/');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84',
'content-type' => 'application/json'
));
$request->setBody('{
"username": "lorem",
"password": "ipsum1$",
"first_name": "John",
"last_name": "Appleseed",
"email": "[email protected]",
"birth_date": "03/07/2016",
"state": "IN-TN",
"batches": ["Test Batch", "UPSC Morning Batch"]
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Java
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"username\": \"lorem\",\n \"password\": \"ipsum1$\",\n \"first_name\": \"John\",\n \"last_name\": \"Appleseed\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\",\n \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.5/admin/users/")
.post(body)
.addHeader("content-type", "application/json")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
NodeJS
var http = require("http");
var options = {
"method": "POST",
"hostname": "demo.testpress.in",
"port": null,
"path": "/api/v2.5/admin/users/",
"headers": {
"content-type": "application/json",
"authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ username: 'lorem',
password: 'ipsum1$',
first_name: 'John',
last_name: 'Appleseed',
birth_date: '03/07/2016',
state: 'IN-TN',
batches: [ 'Test Batch', 'UPSC Morning Batch' ] }));
req.end();

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "http://demo.testpress.in/api/v2.5/admin/users/"
payload := strings.NewReader("{\n \"username\": \"lorem\",\n \"password\": \"ipsum1$\",\n \"first_name\": \"John\",\n \"last_name\": \"Appleseed\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\",\n \"batches\": [\"Test Batch\", \"UPSC Morning Batch\"]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAyMjk2MDd9.ynLE30wWup2CXMqgpNjT4ZBAUAtttqebzat-stuVB84")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}

View User

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

HTTP Request

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

URL Parameters

Parameter

Description

id

Unique Id of the user to retrieve

Fields

Name

Type

Description

username

string

Username of the user

first_name

string

First name of the user

last_name

string

Last name of the user

display_name

string

Name of the user to be displayed

email

string

Email of the user

photo

string

Original image of the user as uploaded

birth_date

datestring

Birth date of user. Should be in DD/MM/YYYY format

gender

string

(Read only) Human readable gender of user. Can be "Male", "Female" or "Transgender"

address1

string

Address of user

address2

string

Address of user

city

string

City of user

zip

string

Pincode of user

state

string

State of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)

phone

string

Phone of user

cURL
Ruby
Python
C#
PHP
Java
NodeJS
Go
cURL
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": "[email protected]", "birth_date": "03/07/2016", "state": "IN-TN"\n}'

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Ruby
require 'uri'
require 'net/http'
url = URI("http://demo.testpress.in/api/v2.5/admin/users/1889/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Get.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"admin15\",\n \"password\": \"demouser\",\n \"first_name\": \"Cool\",\n \"last_name\": \"dude\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\"\n}"
response = http.request(request)
puts response.read_body

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Python
import requests
url = "http://demo.testpress.in/api/v2.5/admin/users/1889/"
payload = "{\n \"username\": \"admin15\",\n \"password\": \"demouser\",\n \"first_name\": \"Cool\",\n \"last_name\": \"dude\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\"\n}"
headers = {
'content-type': "application/json",
'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
'cache-control': "no-cache"
}
response = requests.request("GET", url, data=payload, headers=headers)
print(response.text)

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
C#
var client = new RestClient("http://demo.testpress.in/api/v2.5/admin/users/1889/");
var request = new RestRequest(Method.GET);
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n \"username\": \"admin15\",\n \"password\": \"demouser\",\n \"first_name\": \"Cool\",\n \"last_name\": \"dude\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
PHP
<?php
$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.5/admin/users/1889/');
$request->setMethod(HTTP_METH_GET);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc',
'content-type' => 'application/json'
));
$request->setBody('{
"username": "admin15",
"password": "demouser",
"first_name": "Cool",
"last_name": "dude",
"email": "[email protected]",
"birth_date": "03/07/2016",
"state": "IN-TN"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Java
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"username\": \"admin15\",\n \"password\": \"demouser\",\n \"first_name\": \"Cool\",\n \"last_name\": \"dude\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\"\n}");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.5/admin/users/1889/")
.get()
.addHeader("content-type", "application/json")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
NodeJS
var http = require("http");
var options = {
"method": "GET",
"hostname": "demo.testpress.in",
"port": null,
"path": "/api/v2.5/admin/users/1889/",
"headers": {
"content-type": "application/json",
"authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
"cache-control": "no-cache"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ username: 'admin15',
password: 'demouser',
first_name: 'Cool',
last_name: 'dude',
birth_date: '03/07/2016',
state: 'IN-TN' }));
req.end();

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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/"
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "http://demo.testpress.in/api/v2.5/admin/users/1889/"
payload := strings.NewReader("{\n \"username\": \"admin15\",\n \"password\": \"demouser\",\n \"first_name\": \"Cool\",\n \"last_name\": \"dude\",\n \"email\": \"[email protected]\",\n \"birth_date\": \"03/07/2016\",\n \"state\": \"IN-TN\"\n}")
req, _ := http.NewRequest("GET", url, payload)
req.Header.Add("content-type", "application/json")
req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
req.Header.Add("cache-control", "no-cache")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}

The above command returns JSON structured like this:

{
"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": "[email protected]",
"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

Parameter

Description

id

Unique Id of the user to update

Fields

Name

Type

Description

username

string

Username of the user

password

string

Password to update the user

first_name

string

First name of the user

last_name

string

Last name of the user

display_name

string

Name of the user to be displayed

email

string

Email of the user

birth_date

datestring

Birth date of user. Should be in DD/MM/YYYY format

gender

string

(Read only) Human readable gender of user. Can be "Male", "Female" or "Transgender"

address1

string

Address of user

address2

string

Address of user

city

string

City of user

zip

string

Pincode of user

state

string

State of user in ISO 3166-2:IN format (https://en.wikipedia.org/wiki/ISO_3166-2:IN)

phone

string

Phone of user

is_active

boolean

Used to activate/deactivate the user. Accepts "true"/"false".

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

cURL
Ruby
Python
C#
PHP
Java
NodeJS
Go
cURL
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}'

The above command returns JSON structured like this:

{
"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"
}
Ruby
require 'uri'
require 'net/http'
url = URI("http://demo.testpress.in/api/v2.5/admin/users/2120/")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Put.new(url)
request["authorization"] = 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc'
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request["postman-token"] = 'e395af73-374f-75e4-4ca2-3751f84b0598'
request.body = "{\n\t\"password\": \"welcome\"\n}"
response = http.request(request)
puts response.read_body

The above command returns JSON structured like this:

{
"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"
}
Python
import requests
url = "http://demo.testpress.in/api/v2.5/admin/users/2120/"
payload = "{\n\t\"password\": \"welcome\"\n}"
headers = {
'authorization': "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
'content-type': "application/json",
'cache-control': "no-cache",
'postman-token': "25ef8298-0a61-7404-3a97-db9d0250ef78"
}
response = requests.request("PUT", url, data=payload, headers=headers)
print(response.text)

The above command returns JSON structured like this:

{
"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"
}
C#
var client = new RestClient("http://demo.testpress.in/api/v2.5/admin/users/2120/");
var request = new RestRequest(Method.PUT);
request.AddHeader("postman-token", "0ce5b8e5-0793-457c-32e7-f5c96be55aa9");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc");
request.AddParameter("application/json", "{\n\t\"password\": \"welcome\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

The above command returns JSON structured like this:

{
"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"
}
PHP
<?php
$request = new HttpRequest();
$request->setUrl('http://demo.testpress.in/api/v2.5/admin/users/2120/');
$request->setMethod(HTTP_METH_PUT);
$request->setHeaders(array(
'postman-token' => '652f45cc-e181-b3e2-706c-47459bb5363e',
'cache-control' => 'no-cache',
'content-type' => 'application/json',
'authorization' => 'JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc'
));
$request->setBody('{
"password": "welcome"
}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}

The above command returns JSON structured like this:

{
"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"
}
Java
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n\t\"password\": \"welcome\"\n}");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.5/admin/users/2120/")
.put(body)
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
.addHeader("content-type", "application/json")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "2d5c843c-b6ee-d38e-7a3b-7a71c0353bc8")
.build();
Response response = client.newCall(request).execute();

The above command returns JSON structured like this:

{
"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"
}
NodeJS
var http = require("http");
var options = {
"method": "PUT",
"hostname": "demo.testpress.in",
"port": null,
"path": "/api/v2.5/admin/users/2120/",
"headers": {
"authorization": "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc",
"content-type": "application/json",
"cache-control": "no-cache",
"postman-token": "a4f44159-0b97-e199-ecca-7c5646324c84"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.write(JSON.stringify({ password: 'welcome' }));
req.end();

The above command returns JSON structured like this:

{
"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"
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "http://demo.testpress.in/api/v2.5/admin/users/2120/"
payload := strings.NewReader("{\n\t\"password\": \"welcome\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MzgsInVzZXJfaWQiOjM4LCJlbWFpbCI6ImRpbmVzaEB0ZXN0cHJlc3MuaW4iLCJleHAiOjE0NzAzNDI4NTB9.Dsc2NZ_q0e3GRaBTArgwkPs81RbQEt-FnH0u_TBs2hc")
req.Header.Add("content-type", "application/json")
req.Header.Add("cache-control", "no-cache")
req.Header.Add("postman-token", "9c29d96f-7ea6-35c9-1d30-8ccb20389d39")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}

The above command returns JSON structured like this:

{
"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"
}

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

Parameter

Description

id

Unique 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.2/admin/users/?email=<:email_id>

URL Parameters

Parameter

Description

email

Email Address of the user

Fields

Name

Type

Description

username

string

Username of the user

first_name

string

First name of the user

last_name

string

Last name of the user

display_name

string

Name of the user to be displayed

email

string

Email of the user

photo

string

Original image of the user as uploaded

large_image

string

Profile image with size 256x256

medium_image

string

Profile image with size 128x128

small_image

string

Profile image with size 48x48

xsmall_image

string

Profile image with size 32x32

mini_image

string

Profile image with size 24x24

birth_date

datestring

Birth date of user. Should be in DD/MM/YYYY format