Create Account

Create an account with specified name.

Only super admin is able to send this request.

post
Create Account

https://environment.lvis.io/api/v2/accounts
Request
Response
Request
Headers
Authorization
required
string
Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
Content-Type
required
string
application/vnd.api+json
Body Parameters
name
required
object
Account name. Must be unique and has size less than 255 symbols.
Response
201: Created
{
"data": {
"id": "a0e8cd9d-cd8a-4b1f-aee6-59cc7280f742",
"type": "accounts",
"attributes": {
"name": "Account Name"
}
}
}
422: Unprocessable Entity
{
"errors": [
{
"detail": "is missing",
"source": {
"pointer": "/data/type"
}
},
{
"detail": "has already been taken",
"source": {
"pointer": "/data/attributes/name"
}
}
]
}

Example

Request
Response
cURL
Request
// POST /api/v2/accounts
// Host: environment.lvis.io
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"type": "accounts",
"attributes": {
"name": "Account Name"
}
}
}
Response
// Status: 201 Created
{
"data": {
"id": "9d1e6838-ee0f-4d18-88b2-ad8e243d1361",
"type": "accounts",
"attributes": {
"name": "Account Name"
}
}
}
cURL
curl --request POST \
--url https://environment.lvis.io/api/v2/accounts \
--header 'Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb' \
--header 'Content-Type: application/vnd.api+json' \
--data '{
"data": {
"type": "accounts",
"attributes": {
"name": "Account Name"
}
}
}'

Here we create an account with name "Account Name" as specified in /data/attributes/name attribute.

Account doesn't need any relation on create.

Account is created within id 9d1e6838-ee0f-4d18-88b2-ad8e243d1361 as we see in /data/id attribute in the response and has name "Account Name".

Validation error on account creation

Here in the example we are tying to create an account with name Account name that already exists.

Returned response with 422(Unprocessable Entity) status and error message.

Request
Response
Request
// POST /api/v2/accounts
// Host: environment.lvis.io
// Authorization: Bearer JmsmU5gZb6xNVUgQGoKcQLvQjRhKAUSb
// Content-Type: application/vnd.api+json
{
"data": {
"type": "accounts",
"attributes": {
"name": "Account name"
}
}
}
Response
// Status: 422 Unprocessable Entity
{
"errors": [
{
"source": {
"pointer": "/data/attributes/name"
},
"detail": "has already been taken"
}
]
}