Api / Marketplace

Users

Integrating an External Application for Users

Introduction

This set of API commands allow you to directly affect users within an instance. If you are providing service to end-users, these APIs will allow you to create, administer and suspend users from your marketplace.

NOTES

  1. In the commands below, ‘MYINSTANCE’ will be replaced with your actual instance ID
  2. For legibility the ”\” at the end of each line were removed

First creation of user

Request

curl -v
-X GET $URL
--header "x-api-key: ${BEARER}"
--header 'Content-Type: application/json'
--data '{
  "method":"createUser",
  "params": {
    "email": "test1@oneoffice.bh",
    "instance": "MYINSTANCE",
    "displayName": "TestUser",
    "password": "demo1234"
  }
}'

Response

STATUS: 200

BODY:

{
  "email":"none2@test.oneoffice.ca",
  "displayName":"New User",
  "profile": {
    "uid":null,
    "title":null,
    "department":null,
    "location":null,
    "phones":[],
    "grade":null
  },
  "isAdmin":false,
  "apps":"{0,0,0}",
  "createdAt":1683471262,
  "settings":"{84,213,10,92}",
  "values": {
    "notificationReminder":3,
    "timezone":null,
    "editorTemplates":null
  },
  "id":2,
  "mainCalendar":2,
  "inbox":7,
  "spam":8,
  "sent":9,
  "trashEmail":10,
  "drafts":12,
  "rootFiles":3,
  "trashFiles":4
}

Re-creating user —> should get error

Request

curl -v \
-X GET $URL \
--header "x-api-key: ${BEARER}" \
--header 'Content-Type: application/json' \
--data '{
  "method":"createUser",
  "params": {
    "email":"test1@oneoffice.bh",
    "password":"demo1234"
  }
}'

Response

STATUS: 400

BODY: "duplicate key value violates unique constraint \"users_email\""

Disabling user

Request

curl -v
-X GET $URL
--header "x-api-key: ${BEARER}"
--header 'Content-Type: application/json'
--data '{
  "method":"updateUserByEmail",
  "params":{
    "email":"test1@oneoffice.bh",
    "isActive":false
  }
}'

Response

STATUS: 200

BODY: true

Activating user

Request

curl -v
-X GET $URL
--header "x-api-key: ${BEARER}"
--header 'Content-Type: application/json'
--data '{
  "method":"updateUserByEmail",
  "params": {
    "email":"test1@oneoffice.bh",
    "isActive":true
  }
}

Response

STATUS: 200 BODY: true

Changing Password

Request

curl -v
-X GET $URL
--header "x-api-key: ${BEARER}"
--header 'Content-Type: application/json'
--data '{
  "method":"resetPasswordByEmail",
  "params":{
    "email":"test1@oneoffice.bh",
    "password":"onemoretime"
  }
}'

Response

STATUS: 200 BODY: true

Getting user

Request

curl -v
-X GET $URL
--header "x-api-key: ${BEARER}"
--header 'Content-Type: application/json'
--data '{
  "method":"getUserByEmail",
  "params": {
    "email":"test1@oneoffice.bh"
  }
}'

Response

STATUS: 200 BODY:

{
  "id":2,
  "instance": "MYINSTANCE",
  "email":"none@test.oneoffice.ca",
  "avatar":"",
  "groups":[],
  "settings":[84,213,10,92],
  "apps":[0,0,0],
  "values":{
    "timezone":null,
    "editorTemplates":null,
    "notificationReminder":3
  },
  "profile":{
    "uid":null,
    "grade":null,
    "title":null,
    "phones":[],
    "location":null,
    "department":null
  },
  "displayName":"John Smith",
  "isActive":true,
  "isAdmin":false,
  "isSysAdmin":false,
  "rootFiles":3,
  "trashFiles":4,
  "inbox":7,
  "spam":8,
  "sent":9,
  "trashEmail":10,
  "drafts":12,
  "mainCalendar":2,
  "token":"",
  tokenExpiresAt":0
}

Have questions?

Still have questions? Talk to support.

All content copyright OneOffice / ZeGenie Inc. -- Unauthorized use is prohibited.