Aller au contenu

Account API

Account

Create a new account

Url: POST /account/

Permissions: create_account

Body

Name Type Description
email String

Email of the account.

password String optional

Password of the account in plain text. Required by default and when strategy.name == "local". Must not be specified otherwise.

username String optional

Username of the account. Deduced from the email address if not provided.

permissions String[] optional

Permissions of the account. Can be any arbitrary array of strings.

roles String[] optional

Roles of the account. Can be any array of Role IDs.

strategy.name String optional

Name of the strategy used to create the Account.
Possible values:
- LDAP: The Account comes from an LDAP directory.
- local: The Account is local to SmartShape.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}

Error 4xx

Name Type Description
409

Conflict

Error-Response:
HTTP/1.1 409 Conflict
{
    "status": 409,
    "detail": "A user with this email address already exists.",
    "title": "Conflict"
}
Example usage:
curl -X POST https://smartshape.io/account/ -H 'Authorization: Bearer <auth_token>' -H 'X-SmartShape-Session: <session_token>' -d '{"email": "test4@smartshape.io", "password": "test"}'

Delete an account

Url: DELETE /account/:accountId

Permissions: delete_account

Parameter

Name Type Description
accountId String

ID of the account to be deleted.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}
Example usage:
curl -X DELETE \
  https://smartshape.io/account/6089543988bb2e000be0092e \
  -H 'Authorization: Bearer <auth_token>' \
  -H 'X-SmartShape-Session: <session_token>'

Get a user avatar

Url: GET /account/avatar/:accountId

Parameter

Name Type Description
accountId String optional

ID of the requested account avatar (optional).

Error 4xx

Name Type Description
404

Not Found

Example usage:
curl -X GET \
  https://smartshape.io/account/avatar/5b3497c46fcfde308ad3b7df \
  -H 'Authorization: Bearer <auth_token>' \
  -H 'X-SmartShape-Session: <session_token>'

List all SmartShape accounts

Url: GET /account/

Permissions: list_accounts

Success-Response:
HTTP/1.1 200 OK
{
   "success": true,
   "accounts": [
     {
        "id": "5fca693d1256352948b5fa9d",
        "username": "test",
        "email": "test@smartshape.io",
        "roles": [],
        "permissions": [],
        "strategy": {
            "name": "local"
        }
     }
   ]
}
Example usage:
curl -X GET https://smartshape.io/account/ -H 'Authorization: Bearer <auth_token>' -H 'X-SmartShape-Session: <session_token>'

List all the permissions of the current SmartShape Account (including the ones specific to the current File)

Url: GET /account/permissions/:file

Parameter

Name Type Description
file String

File id

Success-Response:
HTTP/1.1 200 OK
{
   "success": true,
   "permissions": [
       "permission_1",
       "permission_2"
   ]
}
Example usage:
curl -X GET https://smartshape.io/account/permissions/ -H 'Authorization: Bearer <auth_token>' -H 'X-SmartShape-Session: <session_token>'

Log account out

Url: GET /account/logout/

Success-Response:
HTTP/1.1 200 OK
{
    "success": true
}
Example usage:
curl -X GET 'https://smartshape.io/account/logout'

Login account

Url: POST /account/login/

Body

Name Type Description
username String optional

Account username (cannot be used with email).

email String optional

Account email (cannot be used with username).

password String

Account password.

Success 200

Name Type Description
success Boolean
email String

Email of the account.

username String

Username of the account.

cookies String

Cookies that contain the JWT.

strategy.name String

Name of the strategy used to create the Account.
Possible values:
- LDAP: The Account comes from an LDAP directory.
- local: The Account is local to SmartShape.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "username": "test",
    "email": "test@smartshape.io",
    "roles": ["6105f15bd5b76604f33330e7"],
    "permissions": [
        "create_account",
        "delete_account"
    ],
    "strategy": {
        "name": "local"
    },
    "id": "60894bafbd56ffadb446065a",
    "cookies": "jsonwebtoken=eyJhbGciOiJSUzI1NiIsInR5cCI6I..."
}

Error 4xx

Name Type Description
401

Unauthorized

Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "Invalid credentials.",
    "title": "Unauthorized"
}
Example usage:
curl -X POST 'https://smartshape.io/account/login/' \
   --data '{
      "username":"test",
      "password":"test"
   }'

Retrieve the details of an account

Url: GET /account/profile/

Success 200

Name Type Description
id String

ID of the account.

username String

Username of the account.

email String

Email of the account.

permissions String[] optional

Permissions specific to the account.

strategy.name String

Name of the strategy used to create the Account.
Possible values:
- LDAP: The Account comes from an LDAP directory.
- local: The Account is local to SmartShape.

roles String[] optional

Roles of the account.

Success-Response:
   HTTP/1.1 200 OK
{
    "username": "test",
    "email": "test@smartshape.io",
    "roles": ["6105f15bd5b76604f33330e7"],
    "permissions": [
        "create_account",
        "delete_account"
    ],
    "strategy": {
        "name": "local"
    },
    "id": "604f33330e76105f15bd5b76"
}
Example usage:
curl -X GET -H 'Authorization: Bearer <auth_token>' -H 'X-SmartShape-Session: <session_token>' 'https://smartshape.io/account/6089543988bb2e000be0092e'

Update an account

Url: PUT /account/:accountId

Permissions: update_account

Parameter

Name Type Description
accountId String

ID of the account to be updated.

Body

Name Type Description
email String

Email of the account.

password String optional

Password of the account in plain text. Required by default and when strategy.name == "local". Must not be specified otherwise.

username String optional

Username of the account. Deduced from the email address if not provided.

permissions String[] optional

Permissions of the account. Can be any arbitrary array of strings.

roles String[] optional

Roles of the account. Can be any array of Role IDs.

strategy.name String optional

Name of the strategy used to create the Account.
Possible values:
- LDAP: The Account comes from an LDAP directory.
- local: The Account is local to SmartShape.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}
Example usage:
curl -X PUT \
  https://smartshape.io/account/5fca693d1256352948b5fa9d \
  -H 'Authorization: Bearer <auth_token>' \
  -H 'X-SmartShape-Session: <session_token>' \
  -H 'Content-Type: application/json' \
  -d '{
      "email": "test6@smartshape.io"
  }'

Contact

Add a contact to the current SmartShape Account

Url: POST /account/contact/

Body

Name Type Description
contactId String optional

ID of the Account to add to our Contact list.

contactEmail String optional

Email of the Account to add to our Contact list.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}

Error 4xx

Name Type Description
400

Bad Request

401

Unauthorized

409

Conflict

Error-Response:
HTTP/1.1 409 Conflict
{
    "status": 409,
    "title": "Conflict",
    "detail": "This contact already exists in the owner contact list.",
    "code": "CONTACT_ALREADY_EXISTS"
 }
Error-Response:
HTTP/1.1 400 Bad Request
{
    "status": 400,
    "title": "Bad Request",
    "detail": "A contact must have at most a contactId or a contactEmail, not both.",
    "code": "TOO_MANY_ARGUMENTS"
 }
Example usage:
curl -X POST -H 'Authorization: Bearer <auth_token>' -H 'X-SmartShape-Session: <session_token>' -d '{"contactId": "e000be0092e6089543988bb2"}' 'https://smartshape.io/account/contact/'

Delete a contact from the current SmartShape Account

Url: DELETE /account/contact/:contactId

Parameter

Name Type Description
contactId String

ID of the Account to remove from our Contact list.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}

Error 4xx

Name Type Description
401

Unauthorized

404

Not Found

Example usage:
curl -X DELETE -H 'Authorization: Bearer <auth_token>' -H 'X-SmartShape-Session: <session_token>' 'https://smartshape.io/account/contact/000be0092e6089543988bb2e'

List all contacts

Url: GET /account/contact/

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "contacts": [{
        "id": "901d404fb446623684892c0d",
        "owner": "5fca693d1256352948b5fa9d",
        "contact": {
            "id": "52948b5fa9d5fca693d12563",
            "username": "test2"
        },
        "date": 1484575956625
    }]
}

Error 4xx

Name Type Description
401

Unauthorized

Example usage:
curl -X GET -H 'Authorization: Bearer <auth_token>' -H 'X-SmartShape-Session: <session_token>' 'https://smartshape.io/account/contact/'

Role

Add a role

Url: POST /account/role/

Body

Name Type Description
name String

Name of the role.

permissions String

Permissions of the role.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}

Error 4xx

Name Type Description
409

Conflict

Error-Response:
HTTP/1.1 409 Conflict
{
    "status": 409,
    "title": "Conflict",
    "detail":"A role with this name already exists."
}
Example usage:
curl -X POST \
  https://smartshape.io/account/role/ \
  -H 'Authorization: Bearer <auth_token>' \
  -H 'X-SmartShape-Session: <session_token>' \
  -d '{
     "name": "Manager",
     "permissions": ["edit_scene_node_attribute"]
  }'

Delete a role

Url: DELETE /account/role/:roleId

Parameter

Name Type Description
roleId String

ID of the role to delete.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}

Error 4xx

Name Type Description
401

Unauthorized

404

Not Found

Example usage:
curl -X DELETE \
  https://smartshape.io/account/role/delete/5b3497c46fcfde308ad3b7df \
  -H 'Authorization: Bearer <auth_token>' \
  -H 'X-SmartShape-Session: <session_token>'

List all roles

Url: GET /account/role/

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "roles": [{
         "id": "5b33af50b6943e69cda5591f",
         "name": "Manager",
         "permissions": [
             "edit_scene_node_attribute"
         ]
     }]
 }
Example usage:
curl -X GET \
   https://smartshape.io/account/role/ \
   -H 'Authorization: Bearer <auth_token>' \
   -H 'X-SmartShape-Session: <session_token>'

Update a role

Url: PUT /account/role/:roleId

Parameter

Name Type Description
roleId String

ID of the role to update.

Body

Name Type Description
name String

Name of the role.

permissions String

Permissions of the role.

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "id": "6089543988bb2e000be0092e"
}

Error 4xx

Name Type Description
404

Not found

Example usage:
curl -X POST \
 'https://smartshape.io/account/role/update/5b3497c46fcfde308ad3b7df' \
 -H 'Authorization: Bearer <auth_token>' \
 -H 'X-SmartShape-Session: <session_token>' \
 -d '{
    "name": "Manager",
    "permissions": ["edit_scene_node_attribute"]
 }'

Session

Create a new Session

Url: POST /account/session

Success 200

Name Type Description
success Boolean
jwt string

the Session JWT

Success-Response:
HTTP/1.1 200 OK
{
    "success": true,
    "jwt": "eyJhbGciOiJSUzI1NiIsInR5cCI6I..."
}

Error 4xx

Name Type Description
401

Unauthorized

402

Payment Required

409

Unauthorized

Error-Response:
HTTP/1.1 402 Payment Required
{
    "error": {
        "status": 402,
        "detail": "No free Token available",
        "title": "Payment Required"
    }
}
Error-Response:
HTTP/1.1 409 Conflict
{
    "error": {
        "status": 409,
        "detail": "A Session already exists for this Account",
        "title": "Conflict"
    }
}
Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "Invalid JWT",
    "title": "Unauthorized"
}
Example usage:
curl -X POST 'https://smartshape.io/account/session' \
    -H 'Authorization: Bearer <auth_token>' \
    -H 'X-SmartShape-Session: <session_token>'

Delete the current Session

Url: DELETE /account/session

Success-Response:
HTTP/1.1 200 OK
{
    "success": true
}

Error 4xx

Name Type Description
401

Unauthorized

Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "Invalid JWT",
    "title": "Unauthorized"
}
Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "Invalid session JWT",
    "title": "Unauthorized"
}
Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "No session found for the current user",
    "title": "Unauthorized"
}
Example usage:
curl -X DELETE \
  https://smartshape.io/account/session \
  -H 'Authorization: Bearer <auth_token>' \
  -H 'X-SmartShape-Session: <session_token>'

Update a Session to keep it alive

Url: PUT /account/session

Success-Response:
HTTP/1.1 200 OK
{
    "success": true
}

Error 4xx

Name Type Description
401

Unauthorized

Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "Invalid JWT",
    "title": "Unauthorized"
}
Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "Invalid session JWT",
    "title": "Unauthorized"
}
Error-Response:
HTTP/1.1 401 Unauthorized
{
    "code": 401,
    "detail": "No session found for the current user",
    "title": "Unauthorized"
}
Example usage:
curl -X PATCH \
  https://smartshape.io/account/session \
  -H 'Authorization: Bearer <auth_token>' \
  -H 'X-SmartShape-Session: <session_token>'

September 11, 2024 September 11, 2024