NAV Navbar
Logo
HTTP

Introduction

The purpose of this document is to provide an in-depth information about Photon CMS API and it’s methods.

Photon CMS API is built using RESTful principles on top of the Laravel PHP framework, and as such can be consumed by a variety of third-party software applications that are agnostic of the programming language and underlying technology that powers Photon CMS.

Postman Collection

Postman collection is provided for easier API testing: https://docs.photoncms.com/photoncms.postman_collection.json

Make sure to download and import the Postman environment, and edit it to change your domain URL accordingly: https://docs.photoncms.com/photoncms.postman_environment.json

Responses

Structure

All responses are in JSON format.

Each response is composed out of two sections:

This structure is always constant, which means even if the body is empty, it will be in the response.

Valdidation errors

Any endpoint that returns a validation error will return an error code 406 and will have the exact structure.

Within the response body, there will be an array error_fields which will contain info about failed rules. Each rule will be indexed with the field name and will contain the failed_rule and a generic Laravel message.

Example response

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "email": {
        "failed_rule": "Unique",
        "message": "The email has already been taken."
      }
    }
  }
}

Throttle

In Photon API throttle represents a number of sequential API calls during an interval of 1 minute to a specific API endpoint. It is not taken into account if calls were successful or not.

API endpoints which use throttle have this information pointed out in the following documentation.

You can use following parameters to configure throttling:

Authentication

A number of Photon API endpoints requires a token based authentication. Photon CMS ships with a default user with an administrative level of access. Default log-in credentials for this user are:

email: [email protected]

password: L!gthsp44d

A token is acquired by logging through the API login method, and you should inject it into every API request which requires authentication (documented for each route). A token can be injected into the HTTP request using one of the three methods:

  1. As an authorization header Authorization: Bearer {{token}}
  2. As a GET parameter named api_token
  3. As an authentication password

Login

Authenticates an API user.

Returns an object describing the logged in user.

Token expiration

You will notice body[token][ttl]=<SOME_VALUE> in the response. This represents the JWT token expiration time in minutes. This value can be set in the .env file under key JWT_TOKEN_TTL and the default value is JWT_TOKEN_TTL=60 which is equivalent to one hour.

Password expiration:

There is an option to have user passwords expire after some predefined period. This option can be manipulated through the .env' file usingJWT_USE_PASSWORD_EXPIRATION_TIMEkey. Default value isJWT_USE_PASSWORD_EXPIRATION_TIME=true`.

If password expiration is active, you can set the expiration period in .env file by setting a value for JWT_PASSWORD_EXPIRATION_TIME. Value is expressed in minutes, and the default is JWT_PASSWORD_EXPIRATION_TIME=129600 which is equivalent to 90days.

There is also an option to set the password history. This will force the user not to use the same password periodically. The value is set in .env file under key MAX_USED_PASSOWRDS_HISTORY. The default value is MAX_USED_PASSOWRDS_HISTORY=13 which means the user will have to have used 13 different passwords before he can use the same password again.

REQUEST

URL:

POST http://photoncms.test/api/auth/login

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Parameter Required Type Description
email Yes string Email of the user being logged in.
password Yes string Password of the user being logged in.

Example: Successful login

Request headers

POST /api/auth/login HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{
    "email": "[email protected]"
    "password": "L!gthsp44d"
}

Response payload

{
  "message": "USER_LOGIN_SUCCESS",
  "body": {
    "user": {
      "id": 1,
      "created_at": "2016-03-30T11:43:28+0000",
      "updated_at": "2016-04-04T07:20:02+0000",
      "anchor_text": "Administrator Administratorson",
      "email": "[email protected]",
      "password": null,
      "first_name": "Administrator",
      "last_name": "Administratorson",
      "confirmed": true,
      "password_created_at": "2016-10-04T00:00:00+0000",
      "profile_image": null,
      "created_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "updated_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "roles": [
        {
          "id": 1,
          "created_at": "2016-09-05T13:54:39+0000",
          "updated_at": "2016-09-05T13:54:39+0000",
          "anchor_text": "Super Administrator",
          "name": "super_administrator",
          "title": "Super Administrator",
          "permissions": [],
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        }
      ],
      "permissions": [],
      "default_currency": null,
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "extensions": null
    },
    "token": {
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cL2Rvd25yb3V0ZS5kZXZcL2FwaVwvYXV0aFwvbG9naW4iLCJpYXQiOjE0NzY2ODY4NDcsImV4cCI6MTQ3Njg1OTY0NywibmJmIjoxNDc2Njg2ODQ3LCJqdGkiOiI4MjIxYmIzZDg0ZmE1MGQwNjA4ZmI0OThkM2ZkZWUxNiJ9.l0Q_q7iN-yFya-7-AOZO2xKvcdl8208_fQIeU1_CWOc",
      "ttl": "2880"
    }
  }
}

Example: Wrong credentials

Request headers

POST /api/auth/login HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Request payload

{
    "email": "[email protected]"
    "password": "wrong"
}

Response payload

{
  "message": "USER_LOGIN_FAILURE_INVALID_CREDENTIALS",
  "body": []
}

Example: Password expired

Request headers

POST /api/auth/login HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Request payload

{
    "email": "[email protected]"
    "password": "L!gthsp44d"
}

Response payload

{
  "message": "PASSWORD_EXPIRED",
  "body": []
}

Missing parameters

Request headers

POST /api/auth/login HTTP/1.1
Accept: application/json
Status: 406 Not Acceptable

Request payload

{
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "email": {
        "failed_rule": "Required",
        "message": "The email field is required."
      },
      "password": {
        "failed_rule": "Required",
        "message": "The password field is required."
      }
    }
  }
}

Example: Too many attempts

Request headers

POST /api/auth/login HTTP/1.1
Accept: application/json
Status: 429 Too Many Requests

Request payload

{
    "email": "[email protected]"
    "password": "wrong"
}

Response payload

{
  "message": "TOO_MANY_ATTEMPTS",
  "body": []
}

Logout

This doesn’t actually logout a user since the API authentication is stateless. This method invalidates the provided token. On the next login, a new token will be generated.

REQUEST

URL:

GET http://photoncms.test/api/auth/logout

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful logout

Request headers

GET /api/auth/logout HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "USER_LOGOUT_SUCCESS",
  "body": []
}

Example: Invalid token

Request headers

GET /api/auth/logout HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 401 Unauthorized

Response payload

{
  "message": "TOKEN_INVALID",
  "body": []
}

Example: Token absent

Request headers

GET /api/auth/logout HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Response payload

{
  "message": "TOKEN_ABSENT",
  "body": []
}

Token Refresh

Refreshes the authentication token.

REQUEST

URL:

GET http://photoncms.test/api/auth/refresh

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful refresh

Request headers

GET /api/auth/refresh HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "TOKEN_REFRESH_SUCCESS",
  "body": {
    "token": {
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cL2Rvd25yb3V0ZS5kZXZcL2FwaVwvYXV0aFwvcmVmcmVzaCIsImlhdCI6MTQ3NjY4ODM3MSwiZXhwIjoxNDc2ODYxMTcxLCJuYmYiOjE0NzY2ODgzNzEsImp0aSI6ImJjNTM4ZThmMjgyYTkzYzQyYjJhNzkzZTZjZmRmMThhIiwiaW1wZXJzb25hdGluZyI6ZmFsc2V9.jgIUh7lMBccrDnZc0_g8jPpHcfKtyHqa6AnNub2VyvQ",
      "ttl": "2880"
    }
  }
}

Example: Invalid token

Request headers

GET /api/auth/refresh HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 401 Unauthorized

Response payload

{
  "message": "TOKEN_INVALID",
  "body": []
}

Example: Token absent

Request headers

GET /api/auth/refresh HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Response payload

{
  "message": "TOKEN_ABSENT",
  "body": []
}

Get logged in user

Retrieves the currently logged in user from the API. Relies on the JWT token to extract the user.

REQUEST

URL:

GET http://photoncms.test/api/auth/me

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful

Request headers

GET /api/auth/me HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "GET_LOGGED_IN_USER_SUCCESS",
  "body": {
    "user": {
      "id": 1,
      "created_at": "2016-03-30T11:43:28+00:00",
      "updated_at": "2016-10-21T18:34:50+00:00",
      "anchor_text": "Administrator Administratorson",
      "email": "[email protected]",
      "password": null,
      "first_name": "Administrator",
      "last_name": "Administratorson",
      "confirmation_code": null,
      "confirmed": true,
      "password_created_at": "2017-03-04T00:00:00+00:00",
      "deleted_at": null,
      "created_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "updated_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "roles": [],
      "permissions": [],
      "profile_image": null,
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "extensions": null
    },
    "impersonating": false
  }
}

Example: Invalid token

Request headers

GET /api/auth/me HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 401 Unauthorized

Response payload

{
  "message": "TOKEN_INVALID",
  "body": []
}

Example: Token absent

Request headers

GET /api/auth/me HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Response payload

{
  "message": "TOKEN_ABSENT",
  "body": []
}

Register

Registers a new user.

New user confirmation:

There is an option to use new user registration confirmation, but users can also be registered without confirmation if necessary. This option is available in .env file under key USE_REGISTRATION_SERVICE_EMAIL and the default value is USE_REGISTRATION_SERVICE_EMAIL=true. If switched on, you should also set a value for REGISTRATION_SERVICE_EMAIL so that the application would know which email address to use to sign the email.

You can also prevent user registration by setting key CAN_REGISTER_USER from .env to false.

REQUEST

URL:

POST http://photoncms.test/api/auth/register

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Parameter Required Type Description
first_name Yes string First name of the new user.
last_name Yes string Last name of the new user.
email Yes string Valid email address for the new user.
password Yes string User password.

Example: Successful registration

Request headers

POST /api/auth/register HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{
    "first_name": "John"
    "last_name": "Doe"
    "email": "[email protected]"
    "password": "L!gthsp44d"
}

Response payload

{
  "message": "USER_REGISTER_SUCCESS",
  "body": {
    "user": {
      "id": 8,
      "created_at": "2016-10-18T10:05:58+0000",
      "updated_at": "2016-10-18T10:05:58+0000",
      "anchor_text": "John Doe",
      "email": "[email protected]",
      "password": null,
      "first_name": "John",
      "last_name": "Doe",
      "confirmed": false,
      "password_created_at": "2016-10-18T10:05:58+0000",
      "profile_image": null,
      "created_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "updated_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "roles": [],
      "permissions": [],
      "extensions": null
    }
  }
}

Example: User already exists

Request headers

POST /api/auth/register HTTP/1.1
Accept: application/json
Status: 406 Not Acceptable

Request payload

{
    "first_name": "John"
    "last_name": "Doe"
    "email": "[email protected]"
    "password": "L!gthsp44d"
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "email": {
        "failed_rule": "Unique",
        "message": "The email has already been taken."
      }
    }
  }
}

Example: Missing parameters

Request headers

POST /api/auth/register HTTP/1.1
Accept: application/json
Status: 406 Not Acceptable

Request payload

{
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "first_name": {
        "failed_rule": "Required",
        "message": "The first name field is required."
      },
      "last_name": {
        "failed_rule": "Required",
        "message": "The last name field is required."
      },
      "email": {
        "failed_rule": "Required",
        "message": "The email field is required."
      },
      "password": {
        "failed_rule": "Required",
        "message": "The password field is required."
      }
    }
  }
}

Register with invitation

Creates a new user from an invitation. No confirmation is necessary after this step since the invitation was emailed to the new user containing this URL.

REQUEST

URL:

POST http://photoncms.test/api/auth/register/<INVITATION_TOKEN>

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Parameter Required Value Description
first_name Yes string First name of the new user
last_name Yes string Last name of the new user
password Yes string User password

Example: Successful invitation

Request headers

POST /api/auth/register/qg41mgJumR8UhCKHd0cq0srHw9tG72 HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{
    "first_name": "John"
    "last_name": "Doe"
    "password": "L!gthsp44d"
}

Response payload

{
  "message": "USER_REGISTER_SUCCESS",
  "body": {
    "user": {
      "id": 8,
      "created_at": "2016-10-18T10:05:58+0000",
      "updated_at": "2016-10-18T10:05:58+0000",
      "anchor_text": "John Doe",
      "email": "[email protected]",
      "password": null,
      "first_name": "John",
      "last_name": "Doe",
      "confirmed": false,
      "password_created_at": "2016-10-18T10:05:58+0000",
      "profile_image": null,
      "created_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "updated_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "roles": [],
      "permissions": [],
      "extensions": null
    }
  }
}

Example: Invalid invitation code

Request headers

POST /api/auth/register/qg41mgJumR8UhCKHd0cq0srHw9tG72 HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Request payload

{
    "first_name": "John"
    "last_name": "Doe"
    "password": "L!gthsp44d"
}

Response payload

{
  "message": "INVALID_USER_INVITATION_CODE",
  "body": []
}


Invitation code is considered invalid if:

Confirm a new user

Confirmes a new unconfirmed user using its confirmation token provided with the registration email.

REQUEST

URL:

GET http://photoncms.test/api/auth/confirm/<CONFIRMATION_TOKEN>

HEADERS:

Parameter Value
Accept application/json

Example: Successful user confirmation

Request headers

GET /api/auth/confirm/u0DWFQTk4p77aLK6DfN3r8XwaNJ74C HTTP/1.1
Accept: application/json
Status: 200 OK

Response payload

{
  "message": "USER_CONFIRMATION_SUCCESS",
  "body": {
    "token": {
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjgsImlzcyI6Imh0dHA6XC9cL2Rvd25yb3V0ZS5kZXZcL2FwaVwvYXV0aFwvY29uZmlybVwvak54WHVneUJ4dFhMTUtBbDlLZzZCWkRoSmhHUVhCIiwiaWF0IjoxNDc2NzAyMjM3LCJleHAiOjE0NzY4NzUwMzcsIm5iZiI6MTQ3NjcwMjIzNywianRpIjoiMDA3NzI2NTgxYWUxNjIzN2FhMjBhYzI1NDVlYTkyYzQifQ.S8Lk0z5eglM6fx8J1WkBDNAAoLHfW9Kl09Sws511B4o",
      "ttl": "2880"
    }
  }
}

Example: Invalid confirmation code

Request headers

GET /api/auth/confirm/u0DWFQTk4p77aLK6DfN3r8XwaNJ74C HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Response payload

{
  "message": "INVALID_USER_CONFIRMATION_CODE",
  "body": []
}


The confirmation code is considered invalid if it:

Example: Too many attempts

Request headers

GET /api/auth/confirm/u0DWFQTk4p77aLK6DfN3r8XwaNJ74C HTTP/1.1
Accept: application/json
Status: 429 Too Many Requests

Response payload

{
  "message": "TOO_MANY_ATTEMPTS",
  "body": []
}

Start impersonation

Starts impersonating a user. After this point, a user will be impersonated until impersonation stop method has been called. Any endpoint of the API will simulate a response for the impersonated user.

The method returns a new JWT token within the response. This token must be used instead of the old one.

REQUEST

URL:

GET http://photoncms.test/api/auth/impersonate/<USER_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful impersonation

Request headers

GET /api/auth/impersonate/2 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "IMPERSONATING_ON",
  "body": {
    "token": {
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cL3Bob3Rvbi5kZXZcL2FwaVwvYXV0aFwvaW1wZXJzb25hdGVcLzIiLCJpYXQiOjE0OTI2OTE1MTgsImV4cCI6MTQ5Mjg2NDMxOCwibmJmIjoxNDkyNjkxNTE4LCJqdGkiOiJiM2M4YmE1M2U2NzgyNDQ4NWFiZjI2YjMwMmQzNGJmOCIsImltcGVyc29uYXRpbmciOiIyIn0.z8LEn_bue1RgzmQ1yFqs-OwYpcBR3Z-L9d1ljBS80zc",
      "ttl": "2880"
    }
  }
}

Example: Impersonation already on

Request headers

GET /api/auth/impersonate/2 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 400 Bad Request

Response payload

{
  "message": "IMPERSONATION_ALREADY_ON",
  "body": []
}

Example: User not found

Request headers

GET /api/auth/impersonate/5 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "IMPERSONATION_FAILED_USER_NOT_FOUND",
  "body": {
    "id": "5"
  }
}

Stop impersonation

Stops impersonating a user.

The method returns a new JWT token within the response. This token must be used instead of the old one.

REQUEST

URL:

GET http://photoncms.test/api/auth/impersonate/stop

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Impersonation stopped

Request headers

GET /api/auth/impersonate/stop HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "IMPERSONATING_OFF",
  "body": {
    "token": {
      "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6Imh0dHA6XC9cL3Bob3Rvbi5kZXZcL2FwaVwvYXV0aFwvaW1wZXJzb25hdGVcL3N0b3AiLCJpYXQiOjE0OTI2OTI1NDIsImV4cCI6MTQ5Mjg2NTM0MiwibmJmIjoxNDkyNjkyNTQyLCJqdGkiOiIwMWU4MDE3Y2M5MzQxMTlmMTMwZGZiMDZkMTdlMDY2YiIsImltcGVyc29uYXRpbmciOmZhbHNlfQ.zyFM5DXuZ0DwlRIzsF_WTGAkYairFEsO8oI-KSQzxuQ",
      "ttl": "2880"
    }
  }
}

Example: Impersonation already off

Request headers

GET /api/auth/impersonate/stop HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 400 Bad Request

Response payload

{
  "message": "IMPERSONATION_ALREADY_OFF",
  "body": []
}

Field Type

Each module field has its own field type. The following section describes manipulation with field types.

Get field types

Retrieves all available field types.

REQUEST

URL:

GET http://photoncms.test/api/field_types

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful

Request headers

GET /api/field_types HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "GET_ALL_FIELD_TYPES_SUCCESS",
  "body": {
    "field_types": [
      {
        "id": 1,
        "type": "input_text",
        "title": "Input Text",
        "laravel_type": "string",
        "is_system": false
      },
      {
        "id": 2,
        "type": "rich_text",
        "title": "Rich Text",
        "laravel_type": "text",
        "is_system": false
      },
      {
        "id": 3,
        "type": "image",
        "title": "Image",
        "laravel_type": "string",
        "is_system": false
      },
      {
        "id": 4,
        "type": "boolean",
        "title": "Boolean",
        "laravel_type": "boolean",
        "is_system": false
      },
      {
        "id": 5,
        "type": "date",
        "title": "Date",
        "laravel_type": "date",
        "is_system": false
      },
      {
        "id": 7,
        "type": "many_to_one",
        "title": "Many to One",
        "laravel_type": "integer",
        "is_system": false
      },
      {
        "id": 8,
        "type": "many_to_many",
        "title": "Many to Many",
        "laravel_type": "",
        "is_system": false
      },
      {
        "id": 9,
        "type": "password",
        "title": "Password",
        "laravel_type": "string",
        "is_system": false
      },
      {
        "id": 10,
        "type": "integer",
        "title": "Integer",
        "laravel_type": "integer",
        "is_system": false
      },
      {
        "id": 11,
        "type": "system_integer",
        "title": "System Integer",
        "laravel_type": "integer",
        "is_system": true
      },
      {
        "id": 12,
        "type": "system_date_time",
        "title": "System Date-time",
        "laravel_type": "datetime",
        "is_system": true
      },
      {
        "id": 13,
        "type": "system_string",
        "title": "System String",
        "laravel_type": "string",
        "is_system": true
      },
      {
        "id": 14,
        "type": "one_to_one",
        "title": "System String",
        "laravel_type": "string",
        "is_system": true
      },
      {
        "id": 15,
        "type": "file",
        "title": "File",
        "laravel_type": "string",
        "is_system": false
      },
      {
        "id": 16,
        "type": "files",
        "title": "Files",
        "laravel_type": "",
        "is_system": false
      },
      {
        "id": 17,
        "type": "one_to_many",
        "title": "One To Many",
        "laravel_type": "",
        "is_system": false
      },
      {
        "id": 18,
        "type": "date_time",
        "title": "Date-time",
        "laravel_type": "datetime",
        "is_system": false
      },
      {
        "id": 19,
        "type": "gallery",
        "title": "Gallery",
        "laravel_type": "integer",
        "is_system": false
      },
      {
        "id": 20,
        "type": "many_to_one_extended",
        "title": "Many to One Extended",
        "laravel_type": "integer",
        "is_system": false
      },
      {
        "id": 21,
        "type": "many_to_many_extended",
        "title": "Many to Many Extended",
        "laravel_type": "",
        "is_system": false
      },
      {
        "id": 22,
        "type": "one_to_one_extended",
        "title": "One to One Extended",
        "laravel_type": "integer",
        "is_system": false
      },
      {
        "id": 23,
        "type": "one_to_many_extended",
        "title": "One To Many Extended",
        "laravel_type": "",
        "is_system": false
      }
    ]
  }
}

Generator

The generator is used to set up the main system functionality. You can CRUD modules and their fields through the generator. Keep in mind that some actions may impact your current storage data, so be sure to back up if you are removing some fields/modules.

Photon Generator uses a built-in transaction controller. Handling of all requests is performed through transactions and in an event of a failure, the transaction is rolled back. In transactions which impact data in tables (for example removing a field), data will still be affected so be sure to back up your data before using the generator!

New Module

Creates a new module.

For a module type reference refer to the Module Types section.

For a full explanation of anchor texts, take a look at Anchor Texts section.

REQUEST

URL:

POST http://photoncms.test/api/modules

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Two collections are passed as parameters: module and fields

module collection:

Parameter Required Type Description
anchor_text No string Stub which will be used to generate human-readable text for each entry representation (explained in Anchor Texts section)
anchor_html No string Stub which will be used to generate human-readable text for each entry representation (explained in Anchor Html section)
slug No string Stub which will be used to generate human-readable text for each entry representation (explained in Slug section)
category No int Module ID of a parent module. If this value is set then each entry of the current module can belong to an entry of the parent module (scope).
icon No string Generic icon name used in Photon CMS frontend.
is_system No boolean (Deprecated) Indicates if the module is a system module and if it should be preserved on Photon Reset.
lazy_loading No boolean Indicates if module entries should be loaded in paginated fashion rather than in one large chunk (e.g. in relational dropdowns).
max_depth No int Maximum nesting depth.
name Yes string Name of the module.
reporting No boolean Indicates if operations over this module (CRUD-ing entries) will be considered as reporting only. If set to true, to save an entry, you would need to provide a positive force flag.
slug No string Stub which will be used to generate url-friendly text for each entry representation (similar to Anchor Text).
table_name Yes string Table name for the module in snake_case notation.
type Yes string Module type (one of the values from Module Types response).

fields collection: An array of fields as explained in the Fields section

Example: Successful module creation - News module

Request headers

POST /api/modules HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "module" : {
    "table_name" : "news",
    "type" : "non_sortable",
    "name" : "News"
  },
  "fields" : {
    {
      "type" : 1,
      "name" : "Title",
      "column_name" : "title",
      "tooltip_text" : "This is the news title.",
      "validation_rules" : "string"
    },
    {
      "type" : 1,
      "name" : "Content",
      "column_name" : "content",
      "tooltip_text" : "This is the news content.",
      "validation_rules" : "string"
    },
    {
      "type" : 7,
      "name" : "Author",
      "related_module" : 18371489158474,
      "relation_name" : "author",
      "tooltip_text" : "This is the news author",
      "validation_rules" : "exists:users,id"
    },
    {
      "type" : 8,
      "name" : "Contributors",
      "related_module" : 18371489158474,
      "relation_name" : "contributors",
      "tooltip_text" : "These are contributors to the news article.",
      "validation_rules" : "exists:users,id"
    }
  }
}

Response payload

{
  "message": "MODULE_CREATION_SUCCESS",
  "body": {
    "module": {
      "id": 18371493114143,
      "category": null,
      "type": "non_sortable",
      "name": "News",
      "table_name": "news",
      "icon": null,
      "anchor_text": null,
      "anchor_html": null,
      "slug": null,
      "created_at": "2017-04-25T09:55:43+00:00",
      "updated_at": "2017-04-25T09:55:43+00:00",
      "lazy_loading": false,
      "reporting": false,
      "max_depth": null,
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "fields": [
        {
          "id": 40,
          "type": 1,
          "name": "Title",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "title",
          "virtual_name": null,
          "tooltip_text": "This is the news  title.",
          "validation_rules": "string",
          "module_id": 18371493114143,
          "order": 0,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "title",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        },
        {
          "id": 41,
          "type": 1,
          "name": "Content",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "content",
          "virtual_name": null,
          "tooltip_text": "This is the news content.",
          "validation_rules": "string",
          "module_id": 18371493114143,
          "order": 1,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "content",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        },
        {
          "id": 42,
          "type": 7,
          "name": "Author",
          "related_module": 18371489158474,
          "relation_name": "author",
          "pivot_table": null,
          "column_name": null,
          "virtual_name": null,
          "tooltip_text": "This is the news author",
          "validation_rules": "int",
          "module_id": 18371493114143,
          "order": 2,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "author",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        },
        {
          "id": 43,
          "type": 8,
          "name": "Contributors",
          "related_module": 18371489158474,
          "relation_name": "contributors",
          "pivot_table": null,
          "column_name": null,
          "virtual_name": null,
          "tooltip_text": "These are contributors to the news article",
          "validation_rules": "int",
          "module_id": 18371493114143,
          "order": 3,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "contributors",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        }
      ]
    }
  }
}


This example shows the successful creation of a News module.

There are 4 fields created with the module:

Example: Bad table name

Request headers

POST /api/modules HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "module" : {
    "table_name" : "news+32-",
    "type" : "non_sortable",
    "name" : "News"
  },
  "fields" : {...}
}

Response payload

{
  "message": "BAD_TABLE_NAME",
  "body": {
    "invalid_characters": [
      "+",
      "-"
    ]
  }
}

Example: Validation error

Request headers

POST /api/modules HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "module" : {
    "table_name" : "news",
    "type" : "non_sortable",
    "name" : "News"
  }
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "module[table_name]": {
        "failed_rule": "Unique",
        "message": "The module.table name has already been taken."
      },
      "fields": {
        "failed_rule": "Required",
        "message": "The fields field is required."
      }
    }
  }
}

Example: Possible transaction errors

Request headers

POST /api/modules HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 500 Error

Response payload

{
  "message": "TRANSACTION_FAILURE_ROLLED_BACK",
  "body": {
    "failed_functions": {
      "MODULE_CREATION_DB_INSERT": {
        "message": "MODULE_SAVE_FROM_DATA_FAILED",
        "body": {
          "data": {
            "table_name": "news",
            "type": "non_sortable",
            "name": "news",
            "icon": "icon-folder-open-alt",
          }
        }
      }
    },
    "failed_rollbacks": [ ]
  }
}

Response payload

{
  "message": "TRANSACTION_FAILURE_ROLLED_BACK",
  "body": {
    "failed_functions": {
      "MODULE_CREATION_FIELD_INSERTS": {
        "message": "FIELD_SAVE_FROM_DATA_FAILED",
        "body": {
          "data": {
            "type": 1,
            "name": "Title",
            "related_module": null,
            "relation_name": null,
            "pivot_table": null,
            "column_name": "confirmed",
            "tooltip_text": "This is a tool tip text",
            "validation_rules": "required|unique:posts|max:255",
            "module_id": 2,
            "order": 0,
          }
        }
      }
    },
    "failed_rollbacks": []
  }
}

Response payload

{
  "message": "TRANSACTION_FAILURE_ROLLED_BACK",
  "body": {
    "failed_functions": {
      "MODULE_CREATION_ADDING_MIGRATION": {
        "message": "MIGRATION_ALREADY_EXISTS",
        "body": []
      }
    },
    "failed_rollbacks": []
  }
}


This example shows a couple of possible transaction errors. Whatever the reason for the failure is, the system response message is TRANSACTION_FAILURE_ROLLED_BACK with an error code 500.

Get Module

Retrieves the specified module with fields.

REQUEST

URL:

GET http://photoncms.test/api/modules/<MODULE_TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Module retrieved successfully

Request headers

GET /api/modules/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "GET_MODULE_INFORMATION_SUCCESS",
  "body": {
    "module": {
      "id": 18371493114143,
      "category": null,
      "type": "non_sortable",
      "name": "News",
      "table_name": "news",
      "icon": null,
      "anchor_text": null,
      "slug": null,
      "created_at": "2017-04-25T09:55:43+00:00",
      "updated_at": "2017-04-25T09:55:43+00:00",
      "lazy_loading": false,
      "reporting": false,
      "max_depth": null,
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "fields": [
        {
          "id": 40,
          "type": 1,
          "name": "Title",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "title",
          "virtual_name": null,
          "tooltip_text": "This is the news  title.",
          "validation_rules": "string",
          "module_id": 18371493114143,
          "order": 0,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "title",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        },
        {
          "id": 41,
          "type": 1,
          "name": "Content",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "content",
          "virtual_name": null,
          "tooltip_text": "This is the news content.",
          "validation_rules": "string",
          "module_id": 18371493114143,
          "order": 1,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "content",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        },
        {
          "id": 42,
          "type": 7,
          "name": "Author",
          "related_module": 18371489158474,
          "relation_name": "author",
          "pivot_table": null,
          "column_name": null,
          "virtual_name": null,
          "tooltip_text": "This is the news author",
          "validation_rules": "int",
          "module_id": 18371493114143,
          "order": 2,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "author",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        },
        {
          "id": 43,
          "type": 8,
          "name": "Contributors",
          "related_module": 18371489158474,
          "relation_name": "contributors",
          "pivot_table": null,
          "column_name": null,
          "virtual_name": null,
          "tooltip_text": "These are contributors to the news article",
          "validation_rules": "int",
          "module_id": 18371493114143,
          "order": 3,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "contributors",
          "created_at": "2017-04-25T09:55:43+00:00",
          "updated_at": "2017-04-25T09:55:43+00:00"
        }
      ]
    }
  }
}

Example: Module doesn’t exist

Request headers

POST /api/modules/blog HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "blog"
  }
}

Update Module

Updates an existing module.

These are some main pointers for module update:

REQUEST

URL:

PUT http://photoncms.test/api/modules/<MODULE_TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Two collections are passed as parameters: module and fields

module collection:

Parameter Type Description
anchor_text string Stub which will be used to generate human-readable text for each entry representation (explained in Anchor Texts section).
anchor_html string Stub which will be used to generate human-readable text for each entry representation (explained in Anchor Html section)
slug string Stub which will be used to generate human-readable text for each entry representation (explained in Slug section)
icon string Generic icon name used in Photon CMS frontend.
is_system boolean (Deprecated) Indicates if the module is a system module and if it should be preserved on Photon Reset.
lazy_loading boolean Indicates if module entries should be loaded in paginated fashion rather than in one large chunk (e.g. in relational dropdowns).
max_depth int Maximum nesting depth.
name string Name of the module.
reporting boolean Indicates if operations over this module (CRUD-ing entries) will be considered as reporting only. If set to true, to save an entry, you would need to provide a positive force flag.
slug string Stub which will be used to generate url-friendly text for each entry representation (similar to Anchor Text).

fields collection: An array of fields as explained in the Fields section

Example: Successful module update - News module

Request headers

PUT /api/modules/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "module" : {
    "name" : "News module",
    "anchor_text" : "{{title}}",
    "icon" : "new_icon"
  },
  "fields" : {
    {
      "id" : 40,
      "name" : "News Heading",
      "tooltip_text" : "This is a news heading.",
      "validation_rules" : "required|unique:news|max:255"
    },
    {
      "type" : 1,
      "name" : "News Content",
      "column_name" : "news_content",
      "tooltip_text" : "This is the news content.",
      "validation_rules" : "string"
    },
    {
      "type" : 8,
      "name" : "Contributors",
      "column_name" : "content",
      "related_module" : 18371489158474,
      "relation_name" : "contributors",
      "pivot_table" : "contributors",
      "tooltip_text" : "These are the article contributors."
    }
  }
}

Response payload

{
  "message": "MODULE_UPDATE_SUCCESS",
  "body": {
    "module": {
      "id": 18371493202669,
      "category": null,
      "type": "non_sortable",
      "name": "News module",
      "table_name": "news",
      "icon": "new_icon",
      "anchor_text": "{{title}}",
      "anchor_html": null,
      "slug": null,
      "created_at": "2017-04-26T10:31:09+00:00",
      "updated_at": "2017-04-26T10:31:15+00:00",
      "lazy_loading": false,
      "reporting": false,
      "max_depth": null,
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "fields": [
        {
          "id": 40,
          "type": 1,
          "name": "News Heading",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "title",
          "virtual_name": null,
          "tooltip_text": "This is a news heading",
          "validation_rules": "required|unique:news|max:255",
          "module_id": 18371493202669,
          "order": 0,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "title",
          "created_at": "2017-04-26T10:31:09+00:00",
          "updated_at": "2017-04-26T10:31:15+00:00"
        },
        {
          "id": 44,
          "type": 1,
          "name": "News Content",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "news_content",
          "virtual_name": null,
          "tooltip_text": null,
          "validation_rules": null,
          "module_id": 18371493202669,
          "order": 1,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "news_content",
          "created_at": "2017-04-26T10:31:15+00:00",
          "updated_at": "2017-04-26T10:31:15+00:00"
        },
        {
          "id": 45,
          "type": 8,
          "name": "Contributors",
          "related_module": 18371489158474,
          "relation_name": "contributors",
          "pivot_table": "contributors",
          "column_name": null,
          "virtual_name": null,
          "tooltip_text": "These are the article contributors",
          "validation_rules": "int",
          "module_id": 18371493202669,
          "order": 2,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "contributors",
          "created_at": "2017-04-26T10:31:15+00:00",
          "updated_at": "2017-04-26T10:31:15+00:00"
        }
      ]
    }
  }
}

Example: Using non-existing field within anchor text

Request headers

PUT /api/modules/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "module" : {
    "name" : "News module",
    "anchor_text" : "{{wrong_field}}",
    "icon" : "new_icon"
  },
  "fields" : {
    {
      "id" : 40,
      "name" : "News Heading",
      "tooltip_text" : "This is a news heading.",
      "validation_rules" : "required|unique:news|max:255"
    },
    {
      "type" : 1,
      "name" : "News Content",
      "column_name" : "news_content",
      "tooltip_text" : "This is the news content.",
      "validation_rules" : "string"
    },
    {
      "type" : 8,
      "name" : "Contributors",
      "column_name" : "content",
      "related_module" : 18371489158474,
      "relation_name" : "contributors",
      "pivot_table" : "contributors",
      "tooltip_text" : "These are the article contributors."
    }
  }
}

Response payload

{
  "message": "TRYING_TO_USE_NON_EXISTING_FIELD_AS_ANCHOR_TEXT",
  "body": {
    "fields": [
      "title"
    ]
  }
}

Example: Non existing module

Request headers

PUT /api/modules/wrong_module HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "wrong_module"
  }
}

Delete Module

Deletes a module.

REQUEST

URL:

DELETE http://photoncms.test/api/modules/<MODULE_TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Success - module deleted

Request headers

DELETE /api/modules/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "MODULE_DELETION_SUCCESS",
  "body": {
    "module": {
      "id": 18371493291768,
      "category": null,
      "type": "non_sortable",
      "name": "News",
      "table_name": "news",
      "icon": null,
      "anchor_text": null,
      "slug": null,
      "created_at": "2017-04-27T11:16:08+00:00",
      "updated_at": "2017-04-27T11:16:08+00:00",
      "lazy_loading": false,
      "reporting": false,
      "max_depth": null,
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "fields": [
        {
          "id": 40,
          "type": 1,
          "name": "Title",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "title",
          "virtual_name": null,
          "tooltip_text": "This is the news  title.",
          "validation_rules": "string",
          "module_id": 18371493291768,
          "order": 0,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "title",
          "created_at": "2017-04-27T11:16:08+00:00",
          "updated_at": "2017-04-27T11:16:08+00:00"
        },
        {
          "id": 41,
          "type": 1,
          "name": "Content",
          "related_module": null,
          "relation_name": null,
          "pivot_table": null,
          "column_name": "content",
          "virtual_name": null,
          "tooltip_text": "This is the news content.",
          "validation_rules": "string",
          "module_id": 18371493291768,
          "order": 1,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "content",
          "created_at": "2017-04-27T11:16:08+00:00",
          "updated_at": "2017-04-27T11:16:08+00:00"
        },
        {
          "id": 42,
          "type": 7,
          "name": "Author",
          "related_module": 18371489158474,
          "relation_name": "author",
          "pivot_table": null,
          "column_name": null,
          "virtual_name": null,
          "tooltip_text": "This is the news author",
          "validation_rules": "int",
          "module_id": 18371493291768,
          "order": 2,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "author",
          "created_at": "2017-04-27T11:16:08+00:00",
          "updated_at": "2017-04-27T11:16:08+00:00"
        },
        {
          "id": 43,
          "type": 8,
          "name": "Contributors",
          "related_module": 18371489158474,
          "relation_name": "contributors",
          "pivot_table": "news_users",
          "column_name": null,
          "virtual_name": null,
          "tooltip_text": "These are contributors to the news article",
          "validation_rules": "int",
          "module_id": 18371493291768,
          "order": 3,
          "editable": true,
          "disabled": false,
          "hidden": false,
          "is_system": false,
          "virtual": false,
          "lazy_loading": false,
          "default": null,
          "nullable": false,
          "local_key": null,
          "foreign_key": null,
          "indexed": false,
          "unique_name": "contributors",
          "created_at": "2017-04-27T11:16:08+00:00",
          "updated_at": "2017-04-27T11:16:08+00:00"
        }
      ]
    }
  }
}

Example: Module doesn’t exist

Request headers

DELETE /api/modules/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "news"
  }
}

Example: Module has relations pointing to it

Request headers

DELETE /api/modules/users HTTP/1.1
Accept: application/json
Status: 403 Forbidden

Response payload

{
  "message": "MODULE_IS_SYSTEM_DELETE_FAILURE",
  "body": {
    "table_name": "users"
  }
}

Get Module List

Gets a list of all modules.

REQUEST

URL:

GET http://photoncms.test/api/modules

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Success - module deleted

Request headers

GET /api/modules HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "GET_ALL_MODULES_SUCCESS",
  "body": {
    "modules": [
      {
        "id": 18371489158474,
        "category": null,
        "type": "non_sortable",
        "name": "Users",
        "table_name": "users",
        "icon": "icon-user",
        "anchor_text": "{{first_name}} {{last_name}}",
        "slug": null,
        "created_at": "2016-04-01T09:17:48+00:00",
        "updated_at": "2016-04-01T11:29:51+00:00",
        "lazy_loading": false,
        "reporting": true,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158475,
        "category": null,
        "type": "non_sortable",
        "name": "Invitations",
        "table_name": "invitations",
        "icon": "icon-external-link",
        "anchor_text": "{{email}} - {{role.title}}",
        "slug": null,
        "created_at": "2016-08-18T08:10:56+00:00",
        "updated_at": "2016-08-18T08:10:56+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158476,
        "category": null,
        "type": "non_sortable",
        "name": "Invitation Statuses",
        "table_name": "invitation_statuses",
        "icon": "icon-list",
        "anchor_text": "{{title}}",
        "slug": null,
        "created_at": "2016-08-18T12:18:07+00:00",
        "updated_at": "2016-08-18T12:18:07+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158477,
        "category": null,
        "type": "non_sortable",
        "name": "Assets",
        "table_name": "assets",
        "icon": "icon-file-alt",
        "anchor_text": "{{file_name}}",
        "slug": null,
        "created_at": "2016-08-30T12:01:17+00:00",
        "updated_at": "2016-08-30T12:01:17+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158478,
        "category": null,
        "type": "non_sortable",
        "name": "Roles",
        "table_name": "roles",
        "icon": "icon-group",
        "anchor_text": "{{title}}",
        "slug": null,
        "created_at": "2016-09-02T12:24:28+00:00",
        "updated_at": "2016-09-02T12:24:28+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158479,
        "category": null,
        "type": "non_sortable",
        "name": "Permissions",
        "table_name": "permissions",
        "icon": "icon-minus-sign",
        "anchor_text": "{{title}}",
        "slug": null,
        "created_at": "2016-09-02T12:43:44+00:00",
        "updated_at": "2016-09-02T12:43:44+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158480,
        "category": null,
        "type": "sortable",
        "name": "Genres",
        "table_name": "genres",
        "icon": null,
        "anchor_text": "Genre: {{name}}",
        "slug": null,
        "created_at": "2016-12-05T09:11:30+00:00",
        "updated_at": "2016-12-05T09:11:30+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158481,
        "category": 18371489158480,
        "type": "multilevel_sortable",
        "name": "Artists",
        "table_name": "artists",
        "icon": null,
        "anchor_text": "Artist: {{name}}",
        "slug": null,
        "created_at": "2016-06-30T06:47:21+00:00",
        "updated_at": "2016-06-30T06:47:21+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158482,
        "category": 18371489158481,
        "type": "multilevel_sortable",
        "name": "Albums",
        "table_name": "albums",
        "icon": null,
        "anchor_text": "Album: {{name}}",
        "slug": null,
        "created_at": "2016-06-30T06:47:36+00:00",
        "updated_at": "2016-06-30T06:47:36+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158483,
        "category": 18371489158482,
        "type": "sortable",
        "name": "Songs",
        "table_name": "songs",
        "icon": null,
        "anchor_text": "Song: {{name}}",
        "slug": null,
        "created_at": "2016-06-30T06:47:53+00:00",
        "updated_at": "2016-06-30T06:47:53+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371489158484,
        "category": null,
        "type": "non_sortable",
        "name": "File Tags",
        "table_name": "file_tags",
        "icon": "icon-tags",
        "anchor_text": "{{title}}",
        "slug": null,
        "created_at": "2016-10-07T07:14:34+00:00",
        "updated_at": "2016-10-07T07:14:34+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371490275109,
        "category": 18371489158482,
        "type": "sortable",
        "name": "Lyrics",
        "table_name": "lyrics",
        "icon": null,
        "anchor_text": "Lyric: {{song_name}}",
        "slug": null,
        "created_at": "2016-06-30T06:47:53+00:00",
        "updated_at": "2016-06-30T06:47:53+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      },
      {
        "id": 18371493291879,
        "category": null,
        "type": "non_sortable",
        "name": "News",
        "table_name": "news",
        "icon": null,
        "anchor_text": null,
        "slug": null,
        "created_at": "2017-04-27T11:17:59+00:00",
        "updated_at": "2017-04-27T11:17:59+00:00",
        "lazy_loading": false,
        "reporting": false,
        "max_depth": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        }
      }
    ]
  }
}

Module Types

Available module types:

Type Description
single_entry Can have only one entry. If the entry hasn’t been created yet, it will be automatically created. The entry cannot be deleted. Suitable for custom configuration options.
non_sortable Regular module with no sorting options.
sortable Entries can be sorted and nested within module entries.
multilevel_sortable Entries can be sorted and nested within module entries and entries of another module. Suitable for products and such which should be nested within categories.

sortable and multilevel_sortable modules can be scoped within entries of a parent module.

Get Module Types

Retrieves a list of all available module types.

REQUEST

URL:

GET http://photoncms.test/api/module_types

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Success

Request headers

GET /api/module_types HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "GET_ALL_MODULE_TYPES_SUCCESS",
  "body": {
    "module_types": [
      {
        "id": 1,
        "type": "single_entry",
        "title": "Single Entry"
      },
      {
        "id": 2,
        "type": "non_sortable",
        "title": "Non Sortable"
      },
      {
        "id": 3,
        "type": "sortable",
        "title": "Sortable"
      },
      {
        "id": 4,
        "type": "multilevel_sortable",
        "title": "Multilevel Sortable"
      }
    ]
  }
}

Module

This section explains how to manipulate module data.

New Module Entry

Creates a new module item entry.

Parameters are dynamic here, so whichever fields you assigned to the module through module generator, you should use them here for inserting according to their validation rules.

REQUEST

URL:

POST http://photoncms.test/api/<TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful data insert

Request headers

POST /api/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
    "title" : "Some title",
    "content" : "Some content",
    "author" : 1
}

Response payload

{
  "message": "SAVE_DYNAMIC_MODULE_ENTRY_SUCCESS",
  "body": {
    "entry": {
      "id": 1,
      "created_at": "2017-04-27T12:53:23+00:00",
      "updated_at": "2017-04-27T12:53:23+00:00",
      "anchor_text": 1,
      "title": "Some title",
      "content": "Some content",
      "created_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "updated_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "author": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-03-04T00:00:00+00:00",
        "deleted_at": null,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "contributors": [],
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "extensions": null
    }
  }
}


The permission_control parameter within any entity tells which action the current user can perform on that given entity.

Example: Validation error

Request headers

POST /api/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
    "title" : "Some title",
    "content" : "Some content"
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "author": {
        "failed_rule": "Required",
        "message": "The author field is required."
      }
    }
  }
}


When dealing with validation errors, use error_fields indexes as names of fields which have errors. The failed_rule within each failed field is a generic Laravel keyword. Also, the message parameter is the Laravel native compiled message.

Get Module Entries

Retrieves all module entries.

REQUEST

URL:

GET http://photoncms.test/api/<TABLE_NAME>

GET parameters:

Parameter Required Value Description
include_relations No boolean Flag that indicate should relations be loaded or not

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful data retrieve

Request headers

GET /api/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "LOAD_DYNAMIC_MODULE_ENTRIES_SUCCESS",
  "body": {
    "entries": [
      {
        "id": 1,
        "created_at": "2017-04-27T12:53:23+00:00",
        "updated_at": "2017-04-27T12:53:23+00:00",
        "anchor_text": "1",
        "title": "Some title",
        "content": "Some content",
        "created_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "updated_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "author": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      }
    ]
  }
}

Example: Module not found

Request headers

GET /api/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "news"
  }
}

Get Module Entry

Retrieves a specific module entry.

REQUEST

URL:

GET http://photoncms.test/api/<TABLE_NAME>/<ITEM_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful data retrieve

Request headers

GET /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "LOAD_DYNAMIC_MODULE_ENTRY_SUCCESS",
  "body": {
    "entry": {
      "id": 1,
      "created_at": "2017-04-27T13:31:09+00:00",
      "updated_at": "2017-04-27T13:31:09+00:00",
      "anchor_text": "1",
      "title": "Some title",
      "content": "Some content",
      "created_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "updated_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "author": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-03-04T00:00:00+00:00",
        "deleted_at": null,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "contributors": [],
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "extensions": null
    }
  }
}

Example: Entry not found

Request headers

GET /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "DYNAMIC_MODULE_ENTRY_NOT_FOUND",
  "body": {
    "id": "1"
  }
}

Example: Module not found

Request headers

GET /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "news"
  }
}

Update Module Entry

Same as inserting new items, parameters are dynamic here, so whichever parameters you assigned to the module through module generator, you should use them here for updating according to their validation rules.

REQUEST

URL:

POST http://photoncms.test/api/<TABLE_NAME>/<ITEM_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful data update

Request headers

POST /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
    "title" : "Changed title",
    "content" : "Changed content"
}

Response payload

{
  "message": "SAVE_DYNAMIC_MODULE_ENTRY_SUCCESS",
  "body": {
    "entry": {
      "id": 1,
      "created_at": "2017-04-27T13:47:32+00:00",
      "updated_at": "2017-04-27T13:48:42+00:00",
      "anchor_text": "1",
      "title": "Changed title",
      "content": "Changed content",
      "created_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "updated_by": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "author": {
        "id": 1,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-21T18:34:50+00:00",
        "anchor_text": "Administrator Administratorson",
        "email": "[email protected]",
        "password": null,
        "first_name": "Administrator",
        "last_name": "Administratorson",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-03-04T00:00:00+00:00",
        "deleted_at": null,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      "contributors": [],
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "extensions": null
    }
  }
}

Example: Entry not found

Request headers

POST /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

{
    "title" : "Changed title",
    "content" : "Changed content"
}

Response payload

{
  "message": "DYNAMIC_MODULE_ENTRY_NOT_FOUND",
  "body": {
    "id": "1"
  }
}

Example: Module not found

Request headers

POST /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

{
    "title" : "Changed title",
    "content" : "Changed content"
}

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "news"
  }
}

Mass Update Module Entries

Updates multiple entries with or without filtering criteria.

Same as inserting new items, parameters are dynamic here, so whichever parameters you assigned to the module through module generator, you should use them here for updating according to their validation rules. Additionally, there is a possibility to filter the items which are supposed to be mass updated.

To filter data pass the parameter filter as an array of matching criteria. Array keys should represent the name of the DB field, and the value should represent the rule. In case you want to filter through relations, the key should be the relation name and the value should be an array with the criteria for the related table.

Filter rules:

REQUEST

URL:

PUT http://photoncms.test/api/<TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
filter No array An array of filter settings

Example: Successful data update

Request headers

PUT /api/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "title" : "Universal title",
  "filter" : {
    "author" : {
      "equal" : 3
    }
  }
}

Response payload

{
  "message": "MASS_UPDATE_DYNAMIC_MODULE_ENTRY_SUCCESS",
  "body": {
    "updated_entries": [
      {
        "id": 3,
        "created_at": "2017-05-04T07:18:06+00:00",
        "updated_at": "2017-05-04T08:36:12+00:00",
        "anchor_text": "Universal title",
        "title": "Universal title",
        "content": "Some content",
        "created_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "updated_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "user1[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 4,
            "created_at": "2017-05-04T09:12:54+00:00",
            "updated_at": "2017-05-04T09:12:54+00:00",
            "anchor_text": "User 3 Userwoman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 3",
            "last_name": "Userwoman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      {
        "id": 4,
        "created_at": "2017-05-04T07:18:15+00:00",
        "updated_at": "2017-05-04T08:36:12+00:00",
        "anchor_text": "Universal title",
        "title": "Universal title",
        "content": "Some content",
        "created_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "updated_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      }
    ],
    "failed_entries": []
  }
}

Example: Data update on no data found

Request headers

PUT /api/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "title" : "Universal title",
  "filter" : {
    "author" : {
      "equal" : 4
    }
  }
}

Response payload

{
  "message": "MASS_UPDATE_DYNAMIC_MODULE_ENTRY_SUCCESS",
  "body": {
    "updated_entries": [],
    "failed_entries": []
  }
}

Example: Module not found

Request headers

PUT /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

{
    "title" : "Changed title",
    "content" : "Changed content"
}

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "news"
  }
}

Delete Module Entry

Deletes a module entry.

REQUEST

URL:

DELETE http://photoncms.test/api/<MODULE_TABLE_NAME>/<ENTRY_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
force No boolean Forces a delete on an entry which has relations pointing to it or has nested or scoped children.

Example: Success - entry deleted

Request headers

DELETE /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "DELETE_DYNAMIC_MODULE_ENTRY_SUCCESS",
  "body": []
}

Example: Module entry has relations

Request headers

DELETE /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 403 Forbidden

Response payload

{
  "message": "CANNOT_DELETE_ENTRY_HAS_RELATIONS",
  "body": {
    "id": "3"
  }
}


In case you want to delete

Example: Module entry has nested or scoped children

Request headers

DELETE /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 403 Forbidden

Response payload

{
  "message": "CANNOT_DELETE_ENTRY_HAS_CHILDREN",
  "body": {
    "id": "3"
  }
}

Example: Module entry has relations force delete

Request headers

DELETE /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request Payload

{
  "force" : true
}

Response payload

{
  "message": "DELETE_DYNAMIC_MODULE_ENTRY_SUCCESS",
  "body": []
}


This example shows force deleting an entry which has relations pointing to it or has nested or scoped children.

Example: Module entry doesn’t exist

Request headers

DELETE /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "DYNAMIC_MODULE_ENTRY_NOT_FOUND",
  "body": {
    "id": "1"
  }
}

Example: Module doesn’t exist

Request headers

DELETE /api/news/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "news"
  }
}

Filter Module Entries

Filters module items using filter parameters. This method also has pagination and sorting built in.

To filter data pass the parameter filter as an array of matching criteria. Array keys should represent the name of the DB field, and the value should represent the rule. In case you want to filter through relations, the key should be the relation name and the value should be an array with the criteria for the related table.

Filter rules:

Pagination options:

Sorting is performed by any column name.

REQUEST

URL:

POST http://photoncms.test/api/filter/<TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
filter No array An array of filter settings
pagination No array An array of pagination settings
sorting No array An array of fields for sorting and their sorting directions respectively
include_relations No boolean Flag that indicate should relations be loaded or not

Example: Filtering by field only

Request headers

POST /api/filter/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "filter" : {
    "author" : {
      "equal" : 2
    }
  }
}

Response payload

{
  "message": "LOAD_DYNAMIC_MODULE_ENTRIES_SUCCESS",
  "body": {
    "entries": [
      {
        "id": 1,
        "created_at": "2017-05-04T07:10:14+00:00",
        "updated_at": "2017-05-04T07:10:14+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "created_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "updated_by": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "author": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      }
    ]
  }
}

Example: Filtering by relation only

Request headers

POST /api/filter/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "filter" : {
    "contributors" : {
      "id" : {
        "equal" : 2
      }
    }
  }
}

Response payload

{
  "message": "LOAD_DYNAMIC_MODULE_ENTRIES_SUCCESS",
  "body": {
    "entries": [
      {
        "id": 1,
        "created_at": "2017-05-04T07:10:14+00:00",
        "updated_at": "2017-05-04T07:10:14+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      {
        "id": 3,
        "created_at": "2017-05-04T07:18:06+00:00",
        "updated_at": "2017-05-04T07:18:06+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 4,
            "created_at": "2017-05-04T09:12:54+00:00",
            "updated_at": "2017-05-04T09:12:54+00:00",
            "anchor_text": "User 3 Userwoman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 3",
            "last_name": "Userwoman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      {
        "id": 4,
        "created_at": "2017-05-04T07:18:15+00:00",
        "updated_at": "2017-05-04T07:18:15+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      }
    ]
  }
}

Example: Filtering by relation with pagination

Request headers

POST /api/filter/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "filter" : {
    "contributors" : {
      "id" : {
        "equal" : 2
      }
    }
  },
  "pagination" : {
    "items_per_page" : 2
  }
}

Response payload

{
  "message": "LOAD_DYNAMIC_MODULE_ENTRIES_SUCCESS",
  "body": {
    "pagination": {
      "total": 3,
      "count": 2,
      "current_page": 1,
      "has_more_pages": true,
      "last_page": 2,
      "per_page": 2
    },
    "entries": [
      {
        "id": 1,
        "created_at": "2017-05-04T07:10:14+00:00",
        "updated_at": "2017-05-04T07:10:14+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      {
        "id": 3,
        "created_at": "2017-05-04T07:18:06+00:00",
        "updated_at": "2017-05-04T07:18:06+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 4,
            "created_at": "2017-05-04T09:12:54+00:00",
            "updated_at": "2017-05-04T09:12:54+00:00",
            "anchor_text": "User 3 Userwoman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 3",
            "last_name": "Userwoman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      }
    ]
  }
}


This example shows how to set pagination properly. The result contains the pagination dataset which should be used for generation of any front-end pagination logic.

Example: Filtering by relation with pagination and setting the exact page

Request headers

POST /api/filter/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "filter" : {
    "contributors" : {
      "id" : {
        "equal" : 2
      }
    }
  },
  "pagination" : {
    "items_per_page" : 2,
    "current_page" : 2
  }
}

Response payload

{
  "message": "LOAD_DYNAMIC_MODULE_ENTRIES_SUCCESS",
  "body": {
    "pagination": {
      "total": 3,
      "count": 1,
      "current_page": 2,
      "has_more_pages": false,
      "last_page": 2,
      "per_page": 2
    },
    "entries": [
      {
        "id": 4,
        "created_at": "2017-05-04T07:18:15+00:00",
        "updated_at": "2017-05-04T07:18:15+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      }
    ]
  }
}


This example shows how to additionally set the current page of pagination. In this case, it also happens to be the last page of results.

Example: Filtering by relation with sorting

Request headers

POST /api/filter/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "filter" : {
    "contributors" : {
      "id" : {
        "equal" : 2
      }
    }
  },
  "sorting" : {
    "id" : "desc"
  }
}

Response payload

{
  "message": "LOAD_DYNAMIC_MODULE_ENTRIES_SUCCESS",
  "body": {
    "entries": [
      {
        "id": 4,
        "created_at": "2017-05-04T07:18:15+00:00",
        "updated_at": "2017-05-04T07:18:15+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      {
        "id": 3,
        "created_at": "2017-05-04T07:18:06+00:00",
        "updated_at": "2017-05-04T07:18:06+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 3,
          "created_at": "2017-05-04T09:12:33+00:00",
          "updated_at": "2017-05-04T09:12:33+00:00",
          "anchor_text": "User 2 Userwoman",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 2",
          "last_name": "Userwoman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 4,
            "created_at": "2017-05-04T09:12:54+00:00",
            "updated_at": "2017-05-04T09:12:54+00:00",
            "anchor_text": "User 3 Userwoman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 3",
            "last_name": "Userwoman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      },
      {
        "id": 1,
        "created_at": "2017-05-04T07:10:14+00:00",
        "updated_at": "2017-05-04T07:10:14+00:00",
        "anchor_text": "Some title",
        "title": "Some title",
        "content": "Some content",
        "author": {
          "id": 1,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-21T18:34:50+00:00",
          "anchor_text": "Administrator Administratorson",
          "email": "[email protected]",
          "password": null,
          "first_name": "Administrator",
          "last_name": "Administratorson",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-03-04T00:00:00+00:00",
          "deleted_at": null,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
            "edit_restrictions": [],
            "crud": {
              "create": true,
              "update": true,
              "delete": true
            }
          },
          "extensions": null
        },
        "contributors": [
          {
            "id": 1,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-21T18:34:50+00:00",
            "anchor_text": "Administrator Administratorson",
            "email": "[email protected]",
            "password": null,
            "first_name": "Administrator",
            "last_name": "Administratorson",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          },
          {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-03-04T00:00:00+00:00",
            "deleted_at": null,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
              "edit_restrictions": [],
              "crud": {
                "create": true,
                "update": true,
                "delete": true
              }
            },
            "extensions": null
          }
        ],
        "permission_control": {
          "edit_restrictions": [],
          "crud": {
            "create": true,
            "update": true,
            "delete": true
          }
        },
        "extensions": null
      }
    ]
  }
}

Example: Module not found

Request headers

POST /api/filter/news HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

...

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "news"
  }
}

Export Module Entry

Exports a module entry to the specified output.

Exported files on the server disk have a limited time to live which will be provided in the response after the file is created.

You can make your own exporters if you wish.

REQUEST

URL:

POST http://photoncms.test/api/export/<TABLE_NAME>/<ENTRY_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
file_type Yes string Type of the exported file (can be XLSX, PDF or CSV)
file_name No string Name of the exported file
action Yes string Exporting action to execute (accepts store, download, and export)
parameters No array Additional parameters for some exporters

Example: Successful exporting

Request headers

POST /api/export/users/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "file_type" : "PDF",
  "action" : "store",
  "file_name" : "testdata"
}

Response payload

{
  "message": "MODULE_DATA_EXPORTED_SUCCESSFULLY",
  "body": {
    "file_name": "http://photon.dev/api/export/download/testdata.pdf",
    "expiration_time": "2017-04-29T09:11:51+0000",
    "ttl": "60"
  }
}

Example: Exporting not supported

Request headers

POST /api/export/users/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "file_type" : "XLSX",
  "action" : "store"
}

Response payload

{
  "message": "EXPORTING_NOT_SUPPORTED",
  "body": []
}

This is an example of a response when the exporter for the specific case doesn’t exist.

Example: Module not found

Request headers

POST /api/export/wrong_module/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

...

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "wrong_module"
  }
}

Export Module Entries

Exports module entries to the specified output.

Exported files on the server disk have a limited time to live which will be provided in the response after the file is created.

You can make your own exporters if you wish.

To filter data pass the parameter filter as an array of matching criteria. Array keys should represent the name of the DB field, and the value should represent the rule. In case you want to filter through relations, the key should be the relation name and the value should be an array with the criteria for the related table.

The functionality also supports sorting.

Filter rules:

REQUEST

URL:

POST http://photoncms.test/api/export/<TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
filter No string An array of filter settings
file_type Yes string Type of the exported file (can be XLSX, PDF or CSV)
file_name No string Name of the exported file
action Yes string Exporting action to execute (accepts store, download, and export)
parameters No array Additional parameters for some exporters
sort No array An array of fields for sorting and their sorting directions respectively

Example: Successful exporting

Request headers

POST /api/export/transactions HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "file_type" : "XLSX",
  "action" : "store",
  "file_name" : "testdata",
  "sort" : {
    "date" : "asc"
  }
}

Response payload

{
  "message": "MODULE_DATA_EXPORTED_SUCCESSFULLY",
  "body": {
    "file_name": "http://photon.dev/api/export/download/testdata.xlsx",
    "expiration_time": "2017-04-29T09:11:51+0000",
    "ttl": "60"
  }
}

Example: Filtering by relation only

Request headers

POST /api/export/users HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "filter" : {
    "first_name" : {
      "equal" : "User 3"
    }
  },
  "file_type" : "XLSX",
  "action" : "store",
  "file_name" : "users",
  "sort" : {
    "date" : "asc"
  }
}

Response payload

{
  "message": "MODULE_DATA_EXPORTED_SUCCESSFULLY",
  "body": {
    "file_name": "http://photon.dev/api/export/download/users.xlsx",
    "expiration_time": "2017-05-04T12:24:32+00:00",
    "ttl": "60"
  }
}

Example: Module not found

Request headers

POST /api/export/wrong_module HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

...

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "wrong_module"
  }
}

Extension Call

Each module can have extender classes written to extend their base functionality. If the extender exists, and there are some external extension methods defined, they can be called through this route.

Route uses parameters after the entry id to provide the call with additional required data. The functionality is executed over a specific entry.

The response here is what the custom method was programmed to return, so there will be no success example.

REQUEST

URL:

GET http://photoncms.test/api/extension_call/<TABLE_NAME>/<ENTRY_ID>/<additional parameters separated with />

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Extension action not found

Request headers

POST /api/extension_call/users/1/undefined_action_test HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 OK

Response payload

{
  "message": "MODULE_EXTENSION_ACTION_NOT_FOUND",
  "body": {
    "action": "undefined_action_test"
  }
}

Example: Extension class not found

Request headers

POST /api/extension_call/genres/1/test HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 OK

Response payload

{
  "message": "MODULE_EXTENSION_CLASS_NOT_FOUND",
  "body": {
    "class": "Photon\\PhotonCms\\Dependencies\\ModuleExtensions\\GenresModuleExtensions"
  }
}

Example: Module entry not found

Request headers

POST /api/extension_call/users/8/test HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 OK

Response payload

{
  "message": "DYNAMIC_MODULE_ENTRY_NOT_FOUND",
  "body": {
    "id": "8"
  }
}

Example: Module not found

Request headers

POST /api/extension_call/wrong_module/8/test HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

...

Response payload

{
  "message": "MODULE_NOT_FOUND",
  "body": {
    "table_name": "wrong_module"
  }
}

Assets

This section explains how to manipulate Assets, Image Sizes, File Tags and Resized Images dynamic modules that comes preset with Photon.

Assets

This is a built-in non sortable module used for file upload. It has relations with File Tags and Resized Images modules that are also built-in.

FIELDS

Field Field Type Description
File Image File for upload. This is virtual field and it is used only for uploading file while creating new asset.
File Name Input Text Human-readable file name. It can not be entered via API, but is instead generated during upload.
Mime Type Input Text File mime type. It can not be entered via API, but is instead generated during upload.
File Size Integer File size. It can not be entered via API, but is instead calculated during upload.
Real Name and Location Input Text File real file name and path in the storage. It can not be entered via API, but is instead generated during upload.
Image Width Integer Image width. It can not be entered via API, but is instead calculated during upload.
Image Height Integer Image height. It can not be entered via API, but is instead calculated during upload.
File Tags Many to Many Assigned file tags. Many to Many relation between Assets and File Tags module.
Resized images One To Many Resized images generated for this asset. They are generated automatically if uploaded asset is image, one for each entry in Resized Images module.

Example: Assets module structure

{
    "message": "GET_MODULE_INFORMATION_SUCCESS",
    "body": {
        "module": {
            "id": 18371489158477,
            "category": null,
            "type": "non_sortable",
            "name": "Assets",
            "table_name": "assets",
            "icon": "fa fa-file-o",
            "anchor_text": "{{file_name}}",
            "anchor_html": null,
            "slug": null,
            "created_at": "2016-08-30T12:01:17+00:00",
            "updated_at": "2016-08-30T12:01:17+00:00",
            "lazy_loading": false,
            "reporting": false,
            "max_depth": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "fields": [
                {
                    "id": 1,
                    "type": 1,
                    "name": "File Name",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "file_name",
                    "virtual_name": null,
                    "tooltip_text": "This is the human-readable file name.",
                    "validation_rules": "string",
                    "module_id": 18371489158477,
                    "order": 0,
                    "editable": false,
                    "disabled": false,
                    "hidden": true,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "file_name",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 2,
                    "type": 1,
                    "name": "Mime Type",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "mime_type",
                    "virtual_name": null,
                    "tooltip_text": "This is the file mime type.",
                    "validation_rules": null,
                    "module_id": 18371489158477,
                    "order": 1,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "mime_type",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 3,
                    "type": 10,
                    "name": "File Size",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "file_size",
                    "virtual_name": null,
                    "tooltip_text": "This is the file size.",
                    "validation_rules": null,
                    "module_id": 18371489158477,
                    "order": 2,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "file_size",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 4,
                    "type": 1,
                    "name": "Real Name and Location",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "storage_file_name",
                    "virtual_name": null,
                    "tooltip_text": "This is the file real file name and path in the storage.",
                    "validation_rules": null,
                    "module_id": 18371489158477,
                    "order": 3,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "storage_file_name",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 5,
                    "type": 10,
                    "name": "Image Width",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "image_width",
                    "virtual_name": null,
                    "tooltip_text": "If asset is image this is it's width in pixels.",
                    "validation_rules": null,
                    "module_id": 18371489158477,
                    "order": 4,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": true,
                    "indexed": false,
                    "unique_name": "image_width",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 6,
                    "type": 10,
                    "name": "Image Height",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "image_height",
                    "virtual_name": null,
                    "tooltip_text": "If asset is image this is it's height in pixels.",
                    "validation_rules": null,
                    "module_id": 18371489158477,
                    "order": 5,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": true,
                    "indexed": false,
                    "unique_name": "image_height",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 7,
                    "type": 8,
                    "name": "File Tags",
                    "related_module": 18371489158484,
                    "relation_name": "tags",
                    "pivot_table": null,
                    "column_name": null,
                    "virtual_name": null,
                    "tooltip_text": "Assigned file tags",
                    "validation_rules": "exists:file_tags,id|required|min:3",
                    "module_id": 18371489158477,
                    "order": 6,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": true,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": true,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "tags",
                    "created_at": "2016-10-07T07:38:15+00:00",
                    "updated_at": "2016-10-07T07:38:15+00:00"
                },
                {
                    "id": 8,
                    "type": 3,
                    "name": "File",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": null,
                    "virtual_name": "file",
                    "tooltip_text": "File for upload",
                    "validation_rules": "file|required",
                    "module_id": 18371489158477,
                    "order": 7,
                    "editable": false,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": true,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "file",
                    "created_at": "2017-04-12T12:50:31+00:00",
                    "updated_at": "2017-04-12T12:50:31+00:00"
                },
                {
                    "id": 32,
                    "type": 17,
                    "name": "Resized images",
                    "related_module": 18371497336072,
                    "relation_name": "resized_images",
                    "pivot_table": null,
                    "column_name": null,
                    "virtual_name": null,
                    "tooltip_text": "Resized images generated for this asset.",
                    "validation_rules": null,
                    "module_id": 18371489158477,
                    "order": 10,
                    "editable": true,
                    "disabled": false,
                    "hidden": true,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": "id",
                    "foreign_key": "image",
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "resized_images",
                    "created_at": "2017-06-13T06:49:50+00:00",
                    "updated_at": "2017-06-13T06:49:50+00:00"
                }
            ]
        }
    }
}

Image Sizes

This is a built-in non sortable module used for defining image sizes that would be used for generating resized images from uploaded Assets.

FIELDS

Field Field Type Description
Name Input Text Image size name.
Width Integer Width of newly generated image of this image size .
Height Integer Height of newly generated image of this image size .
Lock width Boolean Flag that indicates if width of new image of this image size should scale during generation or remain locked.
Lock height Boolean Flag that indicates if height of new image of this image size should scale during generation or remain locked.
Active Boolean Flag that indicate if specific image size if active or not. Non active image sizes will not be shown in photon’s native frontend app. All newly created image sizes are inactive by default until user rebuilds resized images of that new image size using Rebuild Resized Images Command

Example: Image Sizes structure

{
    "message": "GET_MODULE_INFORMATION_SUCCESS",
    "body": {
        "module": {
            "id": 18371497336721,
            "category": null,
            "type": "non_sortable",
            "name": "Image sizes",
            "table_name": "image_sizes",
            "icon": null,
            "anchor_text": "{{name}}",
            "anchor_html": null,
            "slug": null,
            "created_at": "2017-06-13T06:52:01+00:00",
            "updated_at": "2017-06-13T06:52:01+00:00",
            "lazy_loading": false,
            "reporting": false,
            "max_depth": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "fields": [
                {
                    "id": 15,
                    "type": 1,
                    "name": "Name",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "name",
                    "virtual_name": null,
                    "tooltip_text": "Image size name.",
                    "validation_rules": "required|string",
                    "module_id": 18371497336721,
                    "order": 0,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "name",
                    "created_at": "2017-06-13T06:52:01+00:00",
                    "updated_at": "2017-06-13T06:52:01+00:00"
                },
                {
                    "id": 16,
                    "type": 10,
                    "name": "Width",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "width",
                    "virtual_name": null,
                    "tooltip_text": "Image width.",
                    "validation_rules": "integer",
                    "module_id": 18371497336721,
                    "order": 1,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "width",
                    "created_at": "2017-06-13T06:52:01+00:00",
                    "updated_at": "2017-06-13T06:52:01+00:00"
                },
                {
                    "id": 17,
                    "type": 10,
                    "name": "Height",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "height",
                    "virtual_name": null,
                    "tooltip_text": "Image height.",
                    "validation_rules": "integer",
                    "module_id": 18371497336721,
                    "order": 2,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "height",
                    "created_at": "2017-06-13T06:52:01+00:00",
                    "updated_at": "2017-06-13T06:52:01+00:00"
                },
                {
                    "id": 18,
                    "type": 4,
                    "name": "Lock width",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "lock_width",
                    "virtual_name": null,
                    "tooltip_text": "Image lock width.",
                    "validation_rules": "boolean",
                    "module_id": 18371497336721,
                    "order": 3,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "lock_width",
                    "created_at": "2017-06-13T06:52:01+00:00",
                    "updated_at": "2017-06-13T06:52:01+00:00"
                },
                {
                    "id": 19,
                    "type": 4,
                    "name": "Lock height",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "lock_height",
                    "virtual_name": null,
                    "tooltip_text": "Image lock height.",
                    "validation_rules": "boolean",
                    "module_id": 18371497336721,
                    "order": 4,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "lock_height",
                    "created_at": "2017-06-13T06:52:01+00:00",
                    "updated_at": "2017-06-13T06:52:01+00:00"
                },
                {
                    "id": 20,
                    "type": 4,
                    "name": "Active",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "active",
                    "virtual_name": null,
                    "tooltip_text": "Is the image size active? Defaults to inactive.",
                    "validation_rules": "boolean",
                    "module_id": 18371497336721,
                    "order": 5,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": "0",
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "active",
                    "created_at": "2017-06-13T06:52:01+00:00",
                    "updated_at": "2017-06-13T06:52:01+00:00"
                }
            ]
        }
    }
}

Resized Images

This is a built-in non sortable module used for storing information about resized image that is generated from Assets module in a way defined by Image Sizes module. For resized images generation you can use either GD or Imagick library which can be specified under key IMAGE_SOFTWARE in .env file.

FIELDS

Field Field Type Description
Top X Integer X coordinate of the top left corner of the cropping area on the original image.
Top Y Integer Y coordinate of the top left corner of the cropping area on the original image.
Width Integer Crop width of resized image.
Height Integer Crop height of resized image.
Image Many to One Many to One relation to original image from Assets module.
Image Width Integer Width of resized image in pixels.
Image Height Integer Height of resized image in pixels.
Image Size Many to One Many to One relation to Image Sizes module.
Mime Type Input Text File mime type. It is generated during resized image generation.
File Size Integer File size. It is generated during resized image generation.
Real Name and Location Input Text File real file name and path in the storage. It is generated during resized image generation.

Example: Resized Images structure

{
    "message": "GET_MODULE_INFORMATION_SUCCESS",
    "body": {
        "module": {
            "id": 18371497336072,
            "category": null,
            "type": "non_sortable",
            "name": "Resized Images",
            "table_name": "resized_images",
            "icon": null,
            "anchor_text": "{{top_x}},{{top_y}} - {{height}},{{width}}",
            "anchor_html": null,
            "slug": null,
            "created_at": "2017-06-13T06:41:12+00:00",
            "updated_at": "2017-06-13T06:41:12+00:00",
            "lazy_loading": false,
            "reporting": false,
            "max_depth": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "fields": [
                {
                    "id": 21,
                    "type": 10,
                    "name": "Top X",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "top_x",
                    "virtual_name": null,
                    "tooltip_text": "Top left x position.",
                    "validation_rules": "integer",
                    "module_id": 18371497336072,
                    "order": 0,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "top_x",
                    "created_at": "2017-06-13T06:41:12+00:00",
                    "updated_at": "2017-06-13T06:41:12+00:00"
                },
                {
                    "id": 22,
                    "type": 10,
                    "name": "Top Y",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "top_y",
                    "virtual_name": null,
                    "tooltip_text": "Top left y position.",
                    "validation_rules": "integer",
                    "module_id": 18371497336072,
                    "order": 1,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "top_y",
                    "created_at": "2017-06-13T06:41:12+00:00",
                    "updated_at": "2017-06-13T06:41:12+00:00"
                },
                {
                    "id": 23,
                    "type": 10,
                    "name": "Width",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "width",
                    "virtual_name": null,
                    "tooltip_text": "Image crop width.",
                    "validation_rules": "integer",
                    "module_id": 18371497336072,
                    "order": 2,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "width",
                    "created_at": "2017-06-13T06:41:12+00:00",
                    "updated_at": "2017-06-13T06:41:12+00:00"
                },
                {
                    "id": 24,
                    "type": 10,
                    "name": "Height",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "height",
                    "virtual_name": null,
                    "tooltip_text": "Image crop height",
                    "validation_rules": "integer",
                    "module_id": 18371497336072,
                    "order": 3,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "height",
                    "created_at": "2017-06-13T06:41:12+00:00",
                    "updated_at": "2017-06-13T06:41:12+00:00"
                },
                {
                    "id": 25,
                    "type": 7,
                    "name": "Image",
                    "related_module": 18371489158477,
                    "relation_name": "image",
                    "pivot_table": null,
                    "column_name": null,
                    "virtual_name": null,
                    "tooltip_text": "This is the original image.",
                    "validation_rules": "integer",
                    "module_id": 18371497336072,
                    "order": 4,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "image",
                    "created_at": "2017-06-13T06:41:12+00:00",
                    "updated_at": "2017-06-13T06:41:12+00:00"
                },
                {
                    "id": 30,
                    "type": 10,
                    "name": "Image Width",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "image_width",
                    "virtual_name": null,
                    "tooltip_text": "Image width in pixels.",
                    "validation_rules": null,
                    "module_id": 18371497336072,
                    "order": 4,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": true,
                    "indexed": false,
                    "unique_name": "image_width",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 31,
                    "type": 10,
                    "name": "Image Height",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "image_height",
                    "virtual_name": null,
                    "tooltip_text": "Image height in pixels.",
                    "validation_rules": null,
                    "module_id": 18371497336072,
                    "order": 4,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": true,
                    "indexed": false,
                    "unique_name": "image_height",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 26,
                    "type": 7,
                    "name": "Image size",
                    "related_module": 18371497336721,
                    "relation_name": "image_size",
                    "pivot_table": null,
                    "column_name": null,
                    "virtual_name": null,
                    "tooltip_text": "This is the image size.",
                    "validation_rules": "integer",
                    "module_id": 18371497336072,
                    "order": 5,
                    "editable": true,
                    "disabled": false,
                    "hidden": false,
                    "is_system": false,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "image_size",
                    "created_at": "2017-06-13T06:55:38+00:00",
                    "updated_at": "2017-06-13T06:55:38+00:00"
                },
                {
                    "id": 27,
                    "type": 1,
                    "name": "Mime Type",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "mime_type",
                    "virtual_name": null,
                    "tooltip_text": "This is the file mime type.",
                    "validation_rules": null,
                    "module_id": 18371497336072,
                    "order": 6,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "mime_type",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 28,
                    "type": 10,
                    "name": "File Size",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "file_size",
                    "virtual_name": null,
                    "tooltip_text": "This is the file size.",
                    "validation_rules": null,
                    "module_id": 18371497336072,
                    "order": 7,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "file_size",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                },
                {
                    "id": 29,
                    "type": 1,
                    "name": "Real Name and Location",
                    "related_module": null,
                    "relation_name": null,
                    "pivot_table": null,
                    "column_name": "storage_file_name",
                    "virtual_name": null,
                    "tooltip_text": "This is the file real file name and path in the storage.",
                    "validation_rules": null,
                    "module_id": 18371497336072,
                    "order": 8,
                    "editable": false,
                    "disabled": true,
                    "hidden": false,
                    "is_system": true,
                    "virtual": false,
                    "lazy_loading": false,
                    "default": null,
                    "local_key": null,
                    "foreign_key": null,
                    "is_default_search_choice": false,
                    "can_create_search_choice": false,
                    "is_active_entry_filter": null,
                    "flatten_to_optgroups": false,
                    "nullable": false,
                    "indexed": false,
                    "unique_name": "storage_file_name",
                    "created_at": "2016-08-30T12:01:17+00:00",
                    "updated_at": "2016-08-30T12:01:17+00:00"
                }
            ]
        }
    }
}

Resize Image Extension Call

This is a built-in functionality for Resized Images module. You can call this route and rebuild the resized image with new cropping data.

REQUEST

URL:

GET http://photoncms.test/api/extension_call/resized_images/<RESIZED_IMAGE_ID>/<x>/<y>/<width>/<height>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
x yes int X coordinate of the top left corner of the cropping area on the original image.
y Yes int Y coordinate of the top left corner of the cropping area on the original image.
width Yes int Width of the cropping area on the original image.
height Yes int Height of the cropping area on the original image.

Example: Image rebuild success

Request headers

POST /api/extension_call/resized_images/2/rebuild/4/5/135/250 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
    "message": "RESIZED_IMAGE_REBUILD_SUCCESS",
    "body": {
        "resized_image": {
            "id": 2,
            "created_at": "2017-06-16T12:34:08+00:00",
            "updated_at": "2017-06-16T12:34:27+00:00",
            "anchor_text": "",
            "top_x": 4,
            "top_y": 5,
            "width": 135,
            "height": 250,
            "mime_type": "image/jpg",
            "file_size": 132794,
            "storage_file_name": "200 s3_Bigthumb160x90.gif",
            "image": 6,
            "image_size": 2,
            "file_url": "http://photon.dev/storage/assets/200 s3_Bigthumb160x90.gif",
            "created_by": {
                "id": 1,
                "created_at": "2016-03-30T11:43:28+00:00",
                "updated_at": "2016-10-21T18:34:50+00:00",
                "anchor_text": "Administrator Administratorson",
                "slug": "",
                "email": "[email protected]",
                "password": null,
                "first_name": "Administrator",
                "last_name": "Administratorson",
                "confirmation_code": null,
                "confirmed": true,
                "password_created_at": "2017-05-04T00:00:00+00:00",
                "deleted_at": null,
                "created_by": 1,
                "updated_by": 1,
                "roles": [],
                "permissions": [],
                "profile_image": null,
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
                },
                "extensions": null
            },
            "updated_by": {
                "id": 1,
                "created_at": "2016-03-30T11:43:28+00:00",
                "updated_at": "2016-10-21T18:34:50+00:00",
                "anchor_text": "Administrator Administratorson",
                "slug": "",
                "email": "[email protected]",
                "password": null,
                "first_name": "Administrator",
                "last_name": "Administratorson",
                "confirmation_code": null,
                "confirmed": true,
                "password_created_at": "2017-05-04T00:00:00+00:00",
                "deleted_at": null,
                "created_by": 1,
                "updated_by": 1,
                "roles": [],
                "permissions": [],
                "profile_image": null,
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
                },
                "extensions": null
                },
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
            },
            "extensions": {
                "Test": "/api/extension_call/resized_images/2/rebuild"
            }
        }
    }
}

Rebuild Resized Images Command

This is a command used to regenerate all resized images for specific image size.

Artisan Command definition

php artisan photon:rebuild-resized-images {sizeId} {--showLog} {--force}

ARGUMENTS:

Parameter Required Description
sizeId Yes Id of image size that needs to be regenerated.
–showLog No Option that indicates if log should be printed out in console.
–force No Option that indicates if resized image should be regenerated if it already exists. By default existing resized images will be skipped.

Password

This section Explains how to manage passwords in Photon.

Change Password

Changes logged in user password.

REQUEST

URL:

POST http://photoncms.test/api/password/change

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
old_password Yes string User’s old password
new_password Yes string User’s new password

Example: Change success

Request headers

POST /api/password/change HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "old_password" : "p4ssw0rd",
  "new_password" : "adm!n!strat0r"
}

Response payload

{
  "message": "PASSWORD_CHANGE_SUCCESS",
  "body": []
}

Example: Validation error

Request headers

POST /api/password/change HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "old_password" : "p4ssw0rd",
  "new_password" : "newone"
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "new_password": {
        "failed_rule": "Regex",
        "message": "The new password format is invalid."
      }
    }
  }
}

Example: Validation error - missing parameters

Request headers

POST /api/password/change HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "old_password": {
        "failed_rule": "Required",
        "message": "The old password field is required."
      },
      "new_password": {
        "failed_rule": "Required",
        "message": "The new password field is required."
      }
    }
  }
}

Request Password Reset

Sends an email with password reset link.

REQUEST

URL:

POST http://photoncms.test/api/password/request_reset

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Parameter Required Value Description
email Yes string User’s email address

Example: Change request success

Request headers

POST /api/password/request_reset HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{
  "email" : "[email protected]"
}

Response payload

{
  "message": "PASSWORD_RESET_REQUEST_SUCCESS",
  "body": []
}

Example: Validation error

Request headers

POST /api/password/request_reset HTTP/1.1
Accept: application/json
Status: 406 Not Acceptable

Request payload

{
  "email" : "[email protected]"
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "email": {
        "failed_rule": "Exists",
        "message": "The selected email is invalid."
      }
    }
  }
}

Example: Throttle limit

Request headers

POST /api/password/request_reset HTTP/1.1
Accept: application/json
Status: 429 Too Many Requests

Request payload

{
  "email" : "[email protected]"
}

Response payload

{
  "message": "TOO_MANY_ATTEMPTS",
  "body": []
}

Password Reset

This method is used to reset a password using a password reset token provided via email which was sent with a previous request.

REQUEST

URL:

POST http://photoncms.test/api/password/reset

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Parameter Required Value Description
token Yes string Reset token provided with the email
email Yes string User’s email address
password Yes string New password

Example: Password change success

Request headers

POST /api/password/reset HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{
  "token" : "a0fa64ad8d90721a1a812b43f916845bdd2583271eb5b44ae48e6eff0b1676ba",
  "email" : "[email protected]",
  "password" : "L!gthsp44d"
}

Response payload

{
  "message": "PASSWORD_RESET_SUCCESS",
  "body": []
}

Example: Invalid token

Request headers

POST /api/password/reset HTTP/1.1
Accept: application/json
Status: 401 Unauthorized

Request payload

{
  "token" : "a0fa64ad8d90721a1a812b43f916845bdd2583271eb5b44ae48e6eff0b1676ba",
  "email" : "[email protected]",
  "password" : "L!gthsp44d"
}

Response payload

{
  "message": "PASSWORD_RESET_INVALID_TOKEN",
  "body": []
}

Example: Validation error

Request headers

POST /api/password/reset HTTP/1.1
Accept: application/json
Status: 406 Not Acceptable

Request payload

{
  "token" : "a0fa64ad8d90721a1a812b43f916845bdd2583271eb5b44ae48e6eff0b1676ba",
  "email" : "[email protected]",
  "password" : "something"
}

Response payload


Example: Password already used

Request headers

POST /api/password/reset HTTP/1.1
Accept: application/json
Status: 406 Not Acceptable

Request payload

{
  "token" : "a0fa64ad8d90721a1a812b43f916845bdd2583271eb5b44ae48e6eff0b1676ba",
  "email" : "[email protected]",
  "password" : "L!gthsp44d"
}

Response payload

{
  "message": "PASSWORD_ALREADY_USED",
  "body": []
}

Example: Throttle limit

Request headers

POST /api/password/reset HTTP/1.1
Accept: application/json
Status: 429 Too Many Requests

Request payload

{
  "token" : "a0fa64ad8d90721a1a812b43f916845bdd2583271eb5b44ae48e6eff0b1676ba",
  "email" : "[email protected]",
  "password" : "L!gthsp44d"
}

Response payload

{
  "message": "TOO_MANY_ATTEMPTS",
  "body": []
}

Menu

This section deals with menus.

Menus have menu items with different menu link types which are explained in their respective sections.

Create a Menu

Creates a new menu.

REQUEST

URL:

POST http://photoncms.test/api/menus

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Type Description
name Yes string Unique name of the menu. This is system-wide.
title No string Title of the menu. This is human-readable.
is_system No boolean Says if the menu is system menu or a custom one.
description No string Description for the menu.
menu_link_types Yes string / array A CSV or array of menu link type IDs which will be available for creating menu items in this menu.
max_depth No int Maximum nesting depth.
min_root No int Minimum number of root entries.

Example: Create menu success

Request headers

POST /api/menus HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "name" : "test_menu",
  "title" : "Test Menu",
  "is_system" : 1,
  "description" : "Some description",
  "menu_link_types" : "1,2",
  "max_depth" : 5,
  "min_root" : 10
}

Response payload

{
  "message": "CREATE_MENU_SUCCESS",
  "body": {
    "menu": {
      "id": 2,
      "name": "test_menu",
      "title": "Test Menu",
      "max_depth": "5",
      "min_root": "10",
      "is_system": true,
      "description": "Some description",
      "created_at": "2017-07-26T10:55:38+00:00",
      "updated_at": "2017-07-26T10:55:38+00:00",
      "menu_link_types": [
        {
          "id": 1,
          "name": "admin_panel_module_link",
          "title": "Admin Panel Module Link",
          "clickable": true,
          "is_system": true,
          "has_generic_icon": true
        },
        {
          "id": 2,
          "name": "static_link",
          "title": "Static Link",
          "clickable": true,
          "is_system": true,
          "has_generic_icon": false
        }
      ],
      "created_by": {
        "id": 2,
        "created_at": "2016-03-30T11:43:28+00:00",
        "updated_at": "2016-10-22T10:29:54+00:00",
        "anchor_text": "User 1 Userman",
        "slug": "",
        "email": "[email protected]",
        "password": null,
        "first_name": "User 1",
        "last_name": "Userman",
        "confirmation_code": null,
        "confirmed": true,
        "password_created_at": "2017-05-04T00:00:00+00:00",
        "deleted_at": null,
        "created_by": 1,
        "updated_by": 1,
        "roles": [],
        "permissions": [],
        "profile_image": null,
        "permission_control": {
        "edit_restrictions": [],
        "crud": {
            "create": true,
            "update": true,
            "delete": true
        }
        },
        "extensions": null
        },
        "updated_by": {
          "id": 2,
          "created_at": "2016-03-30T11:43:28+00:00",
          "updated_at": "2016-10-22T10:29:54+00:00",
          "anchor_text": "User 1 Userman",
          "slug": "",
          "email": "[email protected]",
          "password": null,
          "first_name": "User 1",
          "last_name": "Userman",
          "confirmation_code": null,
          "confirmed": true,
          "password_created_at": "2017-05-04T00:00:00+00:00",
          "deleted_at": null,
          "created_by": 1,
          "updated_by": 1,
          "roles": [],
          "permissions": [],
          "profile_image": null,
          "permission_control": {
              "edit_restrictions": [],
              "crud": {
                  "create": true,
                  "update": true,
                  "delete": true
              }
          },
          "extensions": null
        }
    }
  }
}

Example: Validation error

Request headers

POST /api/menus HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "title" : "Test Menu",
  "is_system" : 1,
  "description" : "Some description",
  "menu_link_types" : "admin_panel_module_link,static_link",
  "max_depth" : 5
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "name": {
        "failed_rule": "Required",
        "message": "The name field is required."
      }
    }
  }
}

Get a Menu

Retrieves a menu by its name or id.

REQUEST

URL:

GET http://photoncms.test/api/menus/<MENU_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Get menu success

Request headers

GET /api/menus/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "LOAD_MENU_SUCCESS",
  "body": {
    "menu": {
      "id": 1,
      "name": "admin_panel_menu",
      "title": "Admin Panel Menu",
      "max_depth": null,
      "min_root": null,
      "is_system": true,
      "description": "This menu is used for the admin panel main left menu.",
      "created_at": "2017-07-26T10:55:38+00:00",
      "updated_at": "2017-07-26T10:55:38+00:00",
      "menu_link_types": [
        {
          "id": 1,
          "name": "admin_panel_module_link",
          "title": "Admin Panel Module Link",
          "clickable": true,
          "is_system": true,
          "has_generic_icon": true
        },
        {
          "id": 3,
          "name": "menu_item_group",
          "title": "Menu Item Group",
          "clickable": false,
          "is_system": true,
          "has_generic_icon": false
        }
      ],
      "created_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        },
        "updated_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        }
    }
  }
}

Example: Menu does not exist

Request headers

GET /api/menus/4 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MENU_NOT_FOUND",
  "body": {
    "menu_id": 4
  }
}

Get all Menus

Retrieves all available menus.

REQUEST

URL:

GET http://photoncms.test/api/menus

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Get menus success

Request headers

GET /api/menus HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "LOAD_MENUS_SUCCESS",
  "body": {
    "menus": [
      {
        "id": 1,
        "name": "admin_panel_menu",
        "title": "Admin Panel Menu",
        "max_depth": null,
        "min_root": null,
        "is_system": true,
        "description": "This menu is used for the admin panel main left menu.",
        "menu_link_types": [
            {
              "id": 1,
              "name": "admin_panel_module_link",
              "title": "Admin Panel Module Link",
              "clickable": true,
              "is_system": true,
              "has_generic_icon": true
            },
            {
              "id": 3,
              "name": "menu_item_group",
              "title": "Menu Item Group",
              "clickable": false,
              "is_system": true,
              "has_generic_icon": false
            }
        ],
        "created_at": "2017-07-26T10:55:38+00:00",
        "updated_at": "2017-07-26T10:55:38+00:00",
        "created_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        },
        "updated_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        }
      },
      {
        "id": 2,
        "name": "test_menu",
        "title": "Test Menu",
        "max_depth": 5,
        "min_root": null,
        "is_system": true,
        "description": "Some description",
        "menu_link_types": [
            {
              "id": 1,
              "name": "admin_panel_module_link",
              "title": "Admin Panel Module Link",
              "clickable": true,
              "is_system": true,
              "has_generic_icon": true
            },
            {
              "id": 3,
              "name": "menu_item_group",
              "title": "Menu Item Group",
              "clickable": false,
              "is_system": true,
              "has_generic_icon": false
            }
        ],
        "created_at": "2017-07-26T10:55:38+00:00",
        "updated_at": "2017-07-26T10:55:38+00:00",
        "created_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        },
        "updated_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        }
      }
    ]
  }
}

Update a Menu

Updates a menu.

REQUEST

URL:

PUT http://photoncms.test/api/menus/<MENU_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Type Description
title No string Title of the menu. This is human-readable.
description No string Description for the menu.
menu_link_types No string / array A CSV or array of menu link type IDs which will be available for creating menu items in this menu.
max_depth No int Maximum nesting depth.
min_root No int Minimum number of root entries.

Example: Update menu success

Request headers

PUT /api/menus/2 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "title" : "Test Menu",
  "description" : "Some description",
  "menu_link_types" : "1,2",
  "max_depth" : 5,
  "min_root" : 5
}

Response payload

{
  "message": "UPDATE_MENU_SUCCESS",
  "body": {
    "menu": {
        "id": 2,
        "name": "test_menu",
        "title": "Test Menu",
        "max_depth": "2",
        "min_root": "5",
        "is_system": true,
        "description": "Some description",
        "menu_link_types": [
            {
                "id": 1,
                "name": "admin_panel_module_link",
                "title": "Admin Panel Module Link",
                "clickable": true,
                "is_system": true,
                "has_generic_icon": true
            },
            {
                "id": 2,
                "name": "static_link",
                "title": "Static Link",
                "clickable": true,
                "is_system": true,
                "has_generic_icon": false
            }
        ],
        "created_at": "2017-07-26T10:55:38+00:00",
        "updated_at": "2017-07-26T10:55:38+00:00",
        "created_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        },
        "updated_by": {
            "id": 2,
            "created_at": "2016-03-30T11:43:28+00:00",
            "updated_at": "2016-10-22T10:29:54+00:00",
            "anchor_text": "User 1 Userman",
            "slug": "",
            "email": "[email protected]",
            "password": null,
            "first_name": "User 1",
            "last_name": "Userman",
            "confirmation_code": null,
            "confirmed": true,
            "password_created_at": "2017-05-04T00:00:00+00:00",
            "deleted_at": null,
            "created_by": 1,
            "updated_by": 1,
            "roles": [],
            "permissions": [],
            "profile_image": null,
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "extensions": null
        }
    }
  }
}

Example: Menu not found

Request headers

PUT /api/menus/11 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

{
  "title" : "Test Menu",
  "is_system" : 1,
  "description" : "Some description",
  "link_types" : "admin_panel_module_link,static_link",
  "max_depth" : 5,
  "min_root" : 15
}

Response payload

{
  "message": "MENU_NOT_FOUND",
  "body": {
    "menu_id": 11
  }
}

Delete a Menu

Deletes a menu.

REQUEST

URL:

DELETE http://photoncms.test/api/menus/<MENU_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Delete menu success

Request headers

DELETE /api/menus/2 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "DELETE_MENU_SUCCESS",
  "body": []
}

Example: Delete failure - system menu

Request headers

DELETE /api/menus/2 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 500 Internal Server Error

Response payload

{
  "message": "DELETE_SYSTEM_MENU_FORBIDDEN",
  "body": {
    "menu_id": 2
  }
}

Example: Menu does not exist

Request headers

DELETE /api/menus/11 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "MENU_NOT_FOUND",
  "body": {
    "menu_id": 11
  }
}

Menu Item

This section deals with menu items within menus.

Menu items belong to menus. Each menu item can be of a different menu link type.

Create a Menu Item

Creates a new menu item.

REQUEST

URL:

POST http://photoncms.test/api/menus/items

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Type Description
menu_id Yes int ID of the menu to which this item will belong to.
menu_link_type_id Yes int ID of the link type. Link types explained in Menu Link Type section.
title Yes string Human readable title of the menu item.
resource_data No json A JSON data collection for the specific menu link type if the selected type requires it. Read more in Menu Link Type section.
entry_data No json A JSON data collection for the specific menu link type if the selected type requires it. Read more in Menu Link Type section.
slug No string Unique system name for the specific item, which can be used as a direct approach to the menu item or replace the actual link.
parent_id No int Id of the parent menu item. This value is null if the menu item is at the root of a menu.
icon No string String representation of an icon. This can be implemented later as a class selector, or some other type of pointer.

Example: Create menu item success

Request headers

POST /api/menus/items HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Request payload

{
  "menu_id" : 2,
  "menu_link_type_id" : 1,
  "title" : "Users Module",
  "resource_data" : "{'id':18371489158474,'table_name':'users'}"
}

Response payload

{
    "message": "CREATE_MENU_ITEM_SUCCESS",
    "body": {
        "menu_item": {
            "id": 1,
            "lft": 1,
            "rgt": 2,
            "parent_id": null,
            "depth": 0,
            "menu_name": "test_menu",
            "menu_link_type_name": "admin_panel_module_link",
            "title": "Users Module",
            "resource_data": "{'id':18371489158474,'table_name':'users'}",
            "entry_data": null,
            "icon": "icon-user",
            "slug": null,
            "link": "localhost/module/users",
            "has_children": false,
            "clickable": true,
            "menu": {
                "id": 2,
                "name": "test_menu",
                "title": "Test Menu",
                "max_depth": 2,
                "is_system": true,
                "description": "Some description"
            },
            "menu_link_type": {
                "id": 1,
                "name": "admin_panel_module_link",
                "title": "Admin Panel Module Link",
                "clickable": true,
                "is_system": true,
                "has_generic_icon": true
            },
            "created_at": "2017-07-26T10:55:38+00:00",
            "updated_at": "2017-07-26T10:55:38+00:00",
            "created_by": {
                "id": 2,
                "created_at": "2016-03-30T11:43:28+00:00",
                "updated_at": "2016-10-22T10:29:54+00:00",
                "anchor_text": "User 1 Userman",
                "slug": "",
                "email": "[email protected]",
                "password": null,
                "first_name": "User 1",
                "last_name": "Userman",
                "confirmation_code": null,
                "confirmed": true,
                "password_created_at": "2017-05-04T00:00:00+00:00",
                "deleted_at": null,
                "created_by": 1,
                "updated_by": 1,
                "roles": [],
                "permissions": [],
                "profile_image": null,
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
                },
                "extensions": null
            },
            "updated_by": {
                "id": 2,
                "created_at": "2016-03-30T11:43:28+00:00",
                "updated_at": "2016-10-22T10:29:54+00:00",
                "anchor_text": "User 1 Userman",
                "slug": "",
                "email": "[email protected]",
                "password": null,
                "first_name": "User 1",
                "last_name": "Userman",
                "confirmation_code": null,
                "confirmed": true,
                "password_created_at": "2017-05-04T00:00:00+00:00",
                "deleted_at": null,
                "created_by": 1,
                "updated_by": 1,
                "roles": [],
                "permissions": [],
                "profile_image": null,
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
                },
                "extensions": null
            }
        }
    }
}

Request headers

POST /api/menus/items HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "menu_id" : 2,
  "menu_link_type_id" : 6,
  "title" : "Users Module",
  "resource_data" : "{'id':18371489158474,'table_name':'users'}"
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "menu_link_type_id": {
        "failed_rule": "Exists",
        "message": "The selected menu link type id is invalid."
      }
    }
  }
}

Example: Slug duplicate

Request headers

POST /api/menus/items HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "menu_id" : 2,
  "menu_link_type_id" : 1,
  "title" : "Users Module",
  "resource_data" : "{'id':18371489158474,'table_name':'users'}",
  "slug" : "users"
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "slug": {
        "failed_rule": "Unique",
        "message": "The slug has already been taken."
      }
    }
  }
}

Example: Parent item not found

Request headers

POST /api/menus/items HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 406 Not Acceptable

Request payload

{
  "menu_id" : "test_menu",
  "menu_link_type_name" : 1,
  "title" : "Users Module",
  "resource_data" : "{'id':18371489158474,'table_name':'users'}",
  "parent_id" : 3
}

Response payload

{
  "message": "VALIDATION_ERROR",
  "body": {
    "error_fields": {
      "parent_id": {
        "failed_rule": "Exists",
        "message": "The selected parent id is invalid."
      }
    }
  }
}

Example: Menu not found

Request headers

POST /api/menus/items HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Request payload

{
  "menu_id" : 5,
  "menu_link_type_id" : 1,
  "title" : "Users Module",
  "resource_data" : "{'id':18371489158474,'table_name':'users'}"
}

Response payload

{
  "message": "MENU_NOT_FOUND",
  "body": {
    "menu_id": 5
  }
}

Get Menu Item

Retrieves menu item.

REQUEST

URL:

GET http://photoncms.test/api/menus/items/<MENU_ITEM_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Get menu items success

Request headers

GET /api/menus/items/1 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
    "message": "LOAD_MENU_ITEM_SUCCESS",
    "body": {
        "menu_item": {
            "id": 1,
            "lft": 1,
            "rgt": 2,
            "parent_id": null,
            "depth": 0,
            "menu_name": "test_menu",
            "menu_link_type_name": "menu_item_group",
            "title": "Users Module",
            "resource_data": "{\\\"module_id\\\":18371489158474,\\\"module_table_name\\\":\\\"users\\\"}",
            "entry_data": null,
            "icon": null,
            "slug": null,
            "link": null,
            "created_at": "2017-07-27T12:06:11+00:00",
            "updated_at": "2017-07-27T12:06:11+00:00",
            "permission_control": {
                "edit_restrictions": [],
                "crud": {
                    "create": true,
                    "update": true,
                    "delete": true
                }
            },
            "has_children": false,
            "clickable": false,
            "menu": {
                "id": 2,
                "name": "test_menu",
                "title": "Test Menu",
                "max_depth": 5,
                "is_system": true,
                "description": "Some description",
                "created_at": "2017-07-27T12:05:35+00:00",
                "updated_at": "2017-07-27T12:05:35+00:00",
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
                },
                "created_by": {
                    "id": 1,
                    "created_at": "2016-03-30T11:43:28+00:00",
                    "updated_at": "2016-10-21T18:34:50+00:00",
                    "anchor_text": "Administrator Administratorson",
                    "slug": "",
                    "email": "[email protected]",
                    "password": null,
                    "first_name": "Administrator",
                    "last_name": "Administratorson",
                    "confirmation_code": null,
                    "confirmed": true,
                    "password_created_at": "2017-05-04T00:00:00+00:00",
                    "deleted_at": null,
                    "created_by": 1,
                    "updated_by": 1,
                    "roles": [],
                    "permissions": [],
                    "profile_image": null,
                    "permission_control": {
                        "edit_restrictions": [],
                        "crud": {
                            "create": true,
                            "update": true,
                            "delete": true
                        }
                    },
                    "extensions": null
                },
                "updated_by": {
                    "id": 1,
                    "created_at": "2016-03-30T11:43:28+00:00",
                    "updated_at": "2016-10-21T18:34:50+00:00",
                    "anchor_text": "Administrator Administratorson",
                    "slug": "",
                    "email": "[email protected]",
                    "password": null,
                    "first_name": "Administrator",
                    "last_name": "Administratorson",
                    "confirmation_code": null,
                    "confirmed": true,
                    "password_created_at": "2017-05-04T00:00:00+00:00",
                    "deleted_at": null,
                    "created_by": 1,
                    "updated_by": 1,
                    "roles": [],
                    "permissions": [],
                    "profile_image": null,
                    "permission_control": {
                        "edit_restrictions": [],
                        "crud": {
                            "create": true,
                            "update": true,
                            "delete": true
                        }
                    },
                    "extensions": null
                }
            },
            "menu_link_type": {
                "id": 3,
                "name": "menu_item_group",
                "title": "Menu Item Group",
                "clickable": false,
                "is_system": true,
                "has_generic_icon": false
            },
            "created_by": {
                "id": 1,
                "created_at": "2016-03-30T11:43:28+00:00",
                "updated_at": "2016-10-21T18:34:50+00:00",
                "anchor_text": "Administrator Administratorson",
                "slug": "",
                "email": "[email protected]",
                "password": null,
                "first_name": "Administrator",
                "last_name": "Administratorson",
                "confirmation_code": null,
                "confirmed": true,
                "password_created_at": "2017-05-04T00:00:00+00:00",
                "deleted_at": null,
                "created_by": 1,
                "updated_by": 1,
                "roles": [],
                "permissions": [],
                "profile_image": null,
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
                },
                "extensions": null
            },
            "updated_by": {
                "id": 1,
                "created_at": "2016-03-30T11:43:28+00:00",
                "updated_at": "2016-10-21T18:34:50+00:00",
                "anchor_text": "Administrator Administratorson",
                "slug": "",
                "email": "[email protected]",
                "password": null,
                "first_name": "Administrator",
                "last_name": "Administratorson",
                "confirmation_code": null,
                "confirmed": true,
                "password_created_at": "2017-05-04T00:00:00+00:00",
                "deleted_at": null,
                "created_by": 1,
                "updated_by": 1,
                "roles": [],
                "permissions": [],
                "profile_image": null,
                "permission_control": {
                    "edit_restrictions": [],
                    "crud": {
                        "create": true,
                        "update": true,
                        "delete": true
                    }
                },
                "extensions": null
            }
        }
    }
}

Example: Get menu items, menu item not found error

Request headers

GET /api/menus/items/10 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
    "message": "MENU_ITEM_NOT_FOUND",
    "body": {
        "item_id": "10"
    }
}

Get Menu Items

Retrieves menu items for a specified menu_name.

REQUEST

URL:

GET http://photoncms.test/api/menus/<MENU_ID>/items

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Get menu items success

Request headers

GET /api/menus/1/items HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
    "message": "LOAD_MENU_ITEMS_SUCCESS",
    "body": {
        "menu_items": [
            {
                "id": 1,
                "lft": 1,
                "rgt": 2,
                "parent_id": null,
                "depth": 0,
                "menu_name": "admin_panel_menu",
                "menu_link_type_name": "admin_panel_module_link",
                "title": "Users Module",
                "resource_data": "{'id':18371489158474,'table_name':'users'}",
                "entry_data": null,
                "icon": "icon-user",
                "slug": "users",
                "link": "localhost/module/users",
                "has_children": false,
                "clickable": true,
                "menu": {
                    "id": 1,
                    "name": "admin_panel_menu",
                    "title": "Admin Panel Menu",
                    "max_depth": null,
                    "is_system": true,
                    "description": "This menu is used for the admin panel main left menu."
                },
                "menu_link_type": {
                    "id": 1,
                    "name": "admin_panel_module_link",
                    "title": "Admin Panel Module Link",
                    "clickable": true,
                    "is_system": true,
                    "has_generic_icon": true
                },
                "created_at": "2017-07-26T10:55:38+00:00",
                "updated_at": "2017-07-26T10:55:38+00:00",
                "created_by": {
                    "id": 2,
                    "created_at": "2016-03-30T11:43:28+00:00",
                    "updated_at": "2016-10-22T10:29:54+00:00",
                    "anchor_text": "User 1 Userman",
                    "slug": "",
                    "email": "[email protected]",
                    "password": null,
                    "first_name": "User 1",
                    "last_name": "Userman",
                    "confirmation_code": null,
                    "confirmed": true,
                    "password_created_at": "2017-05-04T00:00:00+00:00",
                    "deleted_at": null,
                    "created_by": 1,
                    "updated_by": 1,
                    "roles": [],
                    "permissions": [],
                    "profile_image": null,
                    "permission_control": {
                        "edit_restrictions": [],
                        "crud": {
                            "create": true,
                            "update": true,
                            "delete": true
                        }
                    },
                    "extensions": null
                },
                "updated_by"