CRUD Users

The /v2/users/login_id endpoint can be used for CRUD manipulations on new and existing users, depending on the role of the user used for the log in step.

GET

Fetch the user data for login_id.

Role permissions:

This operation is permitted for Basic User and Business User roles.

Headers
Accept: application/json
Cookies: < login cookies >
HTTP Response

200 OK

  • The user information is successfully retrieved. The response body should contain a JSON structure with the user’s email address Eg: {"login_id": "johndoe@aol.com"}

403 FORBIDDEN

  • No user matching login_id can be found or insufficient permissions to view that user’s data.

404 NOT FOUND

  • No user matching login_id can be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the login request. Please try again.
Example

Curl

#!/bin/sh
curl -b cookie_user.txt -i -X GET https://api.mediumone.com/v2/users/john.doe@mediumone.com --header "Content-Type: application/json"

Python

import requests
import json

headers ={'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'john.doe@mediumone.com', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

headers = {'Accept': 'application/json'}

response = session.get('https://api.mediumone.com/v2/users/john.doe@mediumone.com', headers=headers)
PATCH

Calling /v2/users/login_id with a PATCH will update the data for the user. Only updating the password or disabling/enabling a basic user is supported at this time.

Role permissions
  • This operation is permitted for Basic User and Business User roles.
Headers
Content-Type: application/json
Accept: application/json
Cookies: < login cookies >
Body

passwordpassword disabled: boolean

HTTP Response

200 OK

  • The user information is successfully updated. The response body contains a JSON document with a list of the fields that were updated Eg: "password"

400 BAD REQUEST

  • The request was missing parameters or the password did not meet minimum complexity requirements

401 UNAUTHORIZED

  • There is no logged in user or the logged in user is not permitted to access the requested user.

404 NOT FOUND

  • The requested user could not be found.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the login request. Please try again.
Examples

Curl

#!/bin/sh
curl -b cookie_user.txt -i -X PATCH -d '{"password":"12345"}' https://api.mediumone.com/v2/users/john.doe@mediumone.com --header "Content-Type: application/json"
curl -b cookie_user.txt -i -X PATCH -d '{"disabled":true}' https://api.mediumone.com/v2/users/john.doe@mediumone.com --header "Content-Type: application/json"

Python

import requests
import json

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'john.doe@mediumone.com', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

headers = {'Accept': 'application/json'}

data = { 'password': '123456', 'disabled': True}         

response = session.patch('https://api.mediumone.com/v2/users/john.doe@mediumone.com', data=json.dumps(data), headers=headers)
POST

Calling /v2/users with a POST will create a new user. Only one user can have a particular email address.

Role permissions

Only users with the role of Business User and Registration User are permitted for this operation.

Headers
Content-Type: application/json
Accept: application/json
Cookies: < login cookies >
Body
  • login_id: user’s login_id
  • password: password
HTTP Response

200 OK

  • The user is successfully created. The response body contains a JSON document with the created user’s email address. Eg: {"login_id": "johndoe@aol.com"}

400 BAD REQUEST

  • The request was missing parameters or the user already exists or the password did not meet minimum complexity requirements.

401 UNAUTHORIZED

  • The HTTP basic auth is invalid, or there is no logged in user or the logged in user is not permitted to access the requested user. 403 FORBIDDEN
  • The user could not be created (eg. the user already exists).

429 TOO MANY REQUESTS

  • The user has sent too many requests in a given amount of time.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the login request. Please try again.
Examples

Curl

#!/bin/sh
curl -b cookie_user.txt -i -X POST -d '{"login_id":"joe.doe@mediumone.com","password":"123456"}' https://api.mediumone.com/v2/users/ --header "Content-Type: application/json"

Python

import requests
import json

headers ={'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'apibusinessuser@mediumone.com', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

data = { 'login_id': 'john.doe@mediumone.com',
         'password': '123456'}

response = session.post('https://api.mediumone.com/v2/users/', data=json.dumps(data), headers=headers)
DELETE

Calling /v2/user/login_id with a DELETE will delete the user identified by login_id. As every event belongs to a user, once a user is deleted, all associated event data will also be deleted.

Role permissions

Only users with the role of Business User are permitted to do this operation.

Headers
Accept: application/json
Cookies: < login cookies >
HTTP Response

204 OK

  • The user is successfully deleted.

403 UNAUTHORIZED

  • There is no logged in user or the logged in user is not permitted to access the requested user.

404 NOT FOUND

  • The user for login_id does not exist.

500 SERVER ERROR

  • Could not complete the request due to an internal server error.

503 SERVICE UNAVAILABLE

  • Temporarily unable to complete the login request. Please try again.
Examples

Curl

#!/bin/sh
curl -b cookie_user.txt -i -X DELETE https://api.mediumone.com/v2/users/john.doe@mediumone.com --header "Content-Type: application/json"

Python

import requests
import json

headers ={'Content-Type': 'application/json', 'Accept': 'application/json'}
data = {'login_id': 'apibusinessuser@mediumone.com', 'password': '12345', 'api_key': 'ABCDEFGHIJKLmnopabcdefghijklmnop1234567890'}

session = requests.session()
response = session.post('https://api.mediumone.com/v2/login', data=json.dumps(data), headers=headers)

headers = {'Accept': 'application/json'}

response = session.delete('https://api.mediumone.com/v2/users/john.doe@mediumone.com', headers=headers)

 

Have more questions? Submit a request

0 Comments

Article is closed for comments.