Internal Companies API

Use the Company API to:

  • Create company.
  • Get companies.
  • Delete company.
  • Update company.

HTTP Headers

The HTTP headers are used to access all RTLS APIs are listed below. Before submitting requests to the company API, set the following headers.

Header Name Example Value Description
X-User-Email admin@example.com Email of the user performing HTTP requests to the API.
X-User-Token Drv3yU7PdyqUMtr89erZ Token allowing user access to the API.

NOTE: Headers are applying to public routes, routes starts with /api/private/... access from localhost and do not require headers

Set header X-USER-EMAIL

Send a request to log in using POST api/auth/log_in.json described in the Auth API. Using the email address returned in the response, set: X-USER-EMAIL = data.email

Set header X-USER-TOKEN

Send a request to log in using POST api/auth/log_in.json described in the Auth API. Using the authentication token returned in the response, set: X-USER-TOKEN = data.token

Set header X-USER-PROJECT

Send a request to get projects using GET api/projects/ described in the Projects API. You must send this request with headers X-USER-EMAIL and X-USER-TOKEN already set. Using the project UID returned in the response, set: X-USER-PROJECT = projects[i].uid

Companies Endpoints

Functionality Method Endpoint
create company POST api/companies
get companies GET api/companies
delete company DELETE api/companies/{uid}
update company PUT api/companies/{uid}

Endpoints

Get companies

GET api/companies

Gets all companies.

Response Fields

Field Description
companies Array of companies
companies[].uid Company unique id
companies[].name Company name
companies[].user_params Company user parameters object, can contains custom fields
companies[].projects Array of company projects
companies[].projects[]....
companies[].users Array of company users
companies[].users[]...

TODO: companies[].projects[].users have too many fields like encrypted_password and refresh_token

Example Response

{
  "companies": [
    {
      "uid": "AA_Dn4M4Tg64gqE6N91RO1",
      "name": "Redpoint Positioning Corp.",
      "user_params": "{\"color\":\"#ff0000\",\"role\":\"Subcontractor\"}",
      "projects": [
        {
          "id": 14,
          "name": "Redpoint Invitations Project",
          "taggings_count": 1,
          "user_params": {
            "color": "#FF3030",
            "role": "PROJECT"
          },
          "uid": "wwqFpxf8QVGh1KZOZFOCrA",
          "scope": "Y",
          "role_uid": "DhE-KsKqEeagPwhgboMCKw",
          "company_uid": "AA_Dn4M4Tg64gqE6N91RO1",
          "privileges": "00000000005",
          "company_name": "Redpoint Positioning Corp.",
          "company_role_uid": "Hyf5F8KqEeagPwhgboMCKw",
          "users": [
            {
              "id": 3,
              "email": "lab@redpointpositioning.com",
              "encrypted_password": "$2a$10$9og1bPP.O/FWcmrLj6Cgp.9RB5m/lUB0mVvb617Oipqp8F4Nr5QqW",
              "last_passwords": null,
              "current_sign_in_at": "2024-02-04T12:46:41.000Z",
              "last_sign_in_at": "2024-02-04T12:46:09.000Z",
              "current_sign_in_ip": "127.0.0.1",
              "last_sign_in_ip": "127.0.0.1",
              "created_at": "2015-05-29T07:37:17.000Z",
              "updated_at": "2024-01-31T08:01:43.000Z",
              "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzSW4iOjEwMzY4MDAwLCJpZCI6Iml3Qy1mWFg5U3V5LUxfRXo2blNCbHciLCJpYXQiOjE3MDY2OTYwNzB9.OTjFVUHyXXI2kuvojkfrFN_Yq9amuEhwYaqDfPR4Lrg",
              "uid": "3e6edsAOEe6v6TbAIGGEcw",
              "company_uid": "AA_Dn4M4Tg64gqE6N91RO1",
              "first_name": null,
              "last_name": null,
              "role": "system_admin",
              "sign_in_count": 42,
              "failed_attempt_count": 0,
              "status": "ACTIVE",
              "password_updated_at": "2015-05-29T07:37:17.000Z",
              "project_uid": "wwqFpxf8QVGh1KZOZFOCrA"
            }
          ]
        }
      ],
      "users": [
        {
          "uid": "YdqHwN37TWmUh16xEtX2yA",
          "email": "ae2project@maila.net",
          "first_name": null,
          "last_name": null,
          "created_at": "2024-01-31T08:01:28.000Z",
          "updated_at": "2024-01-31T08:01:28.000Z"
        }
      ]
    },
    {
      "uid": "l3NrFWXXSqehQCVBShslxg",
      "name": "Skanska",
      "user_params": "{}",
      "projects": [],
      "users": [
        {
          "uid": "YaH6NIgfSXWW96y31NUxpw",
          "email": "admin@skanska.com_O1GptYIcSwKYgrLijrgGUA",
          "first_name": "admin",
          "last_name": "skanska",
          "created_at": "2024-02-04T12:46:41.000Z",
          "updated_at": "2024-02-04T12:46:41.000Z"
        }
      ]
    },
    {
      "uid": "921k-Fq4R2izQNG-q0aMsA",
      "name": "Skanska Two",
      "user_params": "{}",
      "projects": [],
      "users": [
        {
          "uid": "6RP7NTmNSQWqJkHItWVJmw",
          "email": "admin2@skanska.com_HZfJILKYSQeBx98DYqVlAQ",
          "first_name": "admin",
          "last_name": "skanska",
          "created_at": "2024-02-04T12:46:41.000Z",
          "updated_at": "2024-02-04T12:46:41.000Z"
        }
      ]
    }
  ]
}

Create company

POST api/companies

TODO: Not any role restriction

Request Fields

Field Required? Type Description
send_invitation optional boolean Flag shows that use from field user will receive an invitation email
company required object Company object
company.name required string Company name
company.user_params optional object Company user parameters object, can contains custom fields
company.uid optional string Company unique id
user optional object User object
user.first_name optional string User first name
user.last_name optional string User last name
user.role optional string User role
  • company_admin
user.email optional string User email (length 5..255 with '@' symbol)
user.company_uid optional string User company unique id
user.password optional string User password No any restriction

Response fields

Field Description
user User object
user.id
user.email User email
user.encrypted_password
user.last_passwords
user.current_sign_in_at
user.last_sign_in_at
user.current_sign_in_ip
user.last_sign_in_ip
user.created_at
user.updated_at
user.refresh_token
user.uid
user.company_uid User company unique id
user.first_name User first name
user.last_name User last name
user.role User role
  • company_admin
user.sign_in_count
user.failed_attempt_count
user.status
user.password_updated_at
user.user_details
user.isSystemUser
company Company object
company.id
company.name Company name
company.taggings_count
company.user_params Company user parameters object, can contains custom fields
company.uid
company.scope
company.role_uid
company.role_name
company.role_display_name

Example Request

TODO: user have too many fields like encrypted_password and refresh_token

{
  "user": {
    "id": 81,
    "email": "admin@skanska.com_6-4_suc2RWStGvVdnXlGsA",
    "encrypted_password": "$2b$04$/gsMt8mbGW7VBA5erLpnpeRgfSaF2ymRsR7kPyk6jQ9XU9cuHnBDu",
    "last_passwords": null,
    "current_sign_in_at": null,
    "last_sign_in_at": null,
    "current_sign_in_ip": null,
    "last_sign_in_ip": null,
    "created_at": "2024-02-01T19:45:26.000Z",
    "updated_at": "2024-02-01T19:45:26.000Z",
    "refresh_token": null,
    "uid": "5FOyrQcuQtCjHnV90GN53w",
    "company_uid": "QOF-4EXzSYq2FDCLW6aw4A",
    "first_name": "admin",
    "last_name": "skanska",
    "role": "company_admin",
    "sign_in_count": 0,
    "failed_attempt_count": 0,
    "status": "ACTIVE",
    "password_updated_at": "2024-02-01T19:45:26.000Z",
    "user_details": null,
    "isSystemUser": false
  },
  "company": {
    "id": 177,
    "name": "Skanska",
    "taggings_count": 0,
    "user_params": {},
    "uid": "QOF-4EXzSYq2FDCLW6aw4A",
    "scope": "Y",
    "role_uid": "Hyf5F8KqEeagPwhgboMCKw",
    "role_name": "Subcontractor",
    "role_display_name": "Company"
  }
}

Errors

Error Status Error Type Error Body Description
422 ValidationError Validation error
422 ValidationError Company exists
422 ValidationError User with exists
422 ValidationError Email already exists
403 Forbidden public_url is not define No public_url set in server configuration

Edit company

Request Fields

Field Required? Type Description
company required object Company object
company.name required string Company name
company.user_params optional object Company user parameters object, can contains custom fields

Response fields

Field Description
company Company object
company.id
company.name
company.taggings_count
company.user_params Company user parameters object, can contains custom fields
company.uid
company.scope
company.role_uid
company.users
company.users[].id
company.users[].email User email
company.users[].encrypted_password
company.users[].last_passwords
company.users[].current_sign_in_at
company.users[].last_sign_in_at
company.users[].current_sign_in_ip
company.users[].last_sign_in_ip
company.users[].created_at
company.users[].updated_at
company.users[].refresh_token
company.users[].uid
company.users[].company_uid User company unique id
company.users[].first_name User first name
company.users[].last_name User last name
company.users[].role User role
  • company_admin
company.users[].sign_in_count
company.users[].failed_attempt_count
company.users[].status
company.users[].password_updated_at
company.projects
company.projects[].id
company.projects[].name
company.projects[].taggings_count
company.projects[].user_params
company.projects[].uid
company.projects[].scope
company.projects[].role_uid
company.projects[].company_uid
company.projects[].privileges
company.projects[].company_name
company.projects[].company_role_uid Company role

Example Request

{
  "company": {
    "name": "new Skanska"
    "user_params": {
      "color": "#00ff00"
    }
  }
}

Example Response

TODO: user have too many fields like encrypted_password and refresh_token

{
  "company": {
    "id": 179,
    "name": "new Skanska",
    "taggings_count": 0,
    "user_params": {
      "0": "{",
      "1": "}",
      "color": "#00ff00"
    },
    "uid": "pXC5LSBHRYS3Ui5aiwERPg",
    "scope": "Y",
    "role_uid": "Hyf5F8KqEeagPwhgboMCKw",
    "users": [
      {
        "id": 83,
        "email": "admin@skanska.com_fwwPRu5lSn20MwEY812ubg",
        "encrypted_password": "$2b$04$J85fXxFtKvOyWwbAZMnteOvipa5KqUoil7mDtkmoacWlBaAQsgd4a",
        "last_passwords": null,
        "current_sign_in_at": "2024-02-01T20:15:52.000Z",
        "last_sign_in_at": null,
        "current_sign_in_ip": null,
        "last_sign_in_ip": null,
        "created_at": "2024-02-01T20:15:52.000Z",
        "updated_at": "2024-02-01T20:15:52.000Z",
        "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzSW4iOjEwMzY4MDAwLCJpZCI6IjZnUGpFV2FHVFRxOHhVZGhlbkU0amciLCJpYXQiOjE3MDY4MTg1NTJ9.YxA0dHXPceObwfbzsys98yfnA9gvrRhvJSisndmbTmo",
        "uid": "jlYr7yfhTU2ymX9qzRMwZQ",
        "company_uid": "pXC5LSBHRYS3Ui5aiwERPg",
        "first_name": "admin",
        "last_name": "skanska",
        "role": "company_admin",
        "sign_in_count": 1,
        "failed_attempt_count": 0,
        "status": "ACTIVE",
        "password_updated_at": "2024-02-01T20:15:52.000Z"
      }
    ],
    "projects": []
  }
}

Errors

Error Status Error Type Error Body Description
422 Validation Error Validation errors
404 Not Found Company with uid not found
422 Validation Error Company with name already exist
403 Forbidden User have no permission to update company User can't update company due to lack of permission. Only system admin ar company admin can update companies .
403 Forbidden User have no permission to update company User can't update company. Company admin can update only it own company.

Delete company

DELETE api/companies/{uid}

Delete a site with a specified site UID. To retrieve a site UID, see get sites.

Returns status 200 for all results.

results matching ""

    No results matching ""