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.

Customizing response payload

By using an include query parameter it is possible to limit what properties are returned in the response payload. Nesting the properties using the dot notation allows customizing the response of the relational data, as well.

EXAMPLE REQUEST

URL:

GET http://photoncms.test/api/users?include[]=id&include[]=created_at&&include[]=created_by.id

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example response

{
    "message": "LOAD_DYNAMIC_MODULE_ENTRIES_SUCCESS",
    "body": {
        "entries": [
            {
                "id": 1,
                "created_at": "2016-03-30T11:43:28+00:00",
                "created_by": {
                    "id": 1
                }
            },
            {
                "id": 2,
                "created_at": "2016-03-30T11:43:28+00:00",
                "created_by": {
                    "id": 1
                }
            }
        ]
    }
}

Validation 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": "[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": {
                    "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,
                "lft": 3,
                "rgt": 4,
                "parent_id": null,
                "depth": 0,
                "menu_name": "admin_panel_menu",
                "menu_link_type_name": "admin_panel_module_link",
                "title": "Assets Module",
                "resource_data": "{'id':18371489158477,'table_name':'assets'}",
                "entry_data": null,
                "icon": "icon-file-alt",
                "slug": "assets",
                "link": "localhost/module/assets",
                "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": {
                    "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: Get menu items error

Request headers

GET /api/menus/4/items 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 Menu Item Ancestors

Retrieves list of ancestor IDs for specific menu item.

REQUEST

URL:

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

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Get menu items success

Request headers

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

Response payload

{
    "message": "LOAD_MENU_ITEM_ANCESTORS_SUCCESS",
    "body": {
        "ancestors": [
            {
                "id": 5
            },
            {
                "id": 4
            },
            {
                "id": 3
            },
            {
                "id": 2
            }
        ]
    }
}

Update a Menu Item

Updates a menu item.

REQUEST

URL:

PUT http://photoncms.test/api/menus/items/<ITEM_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Type Description
menu_link_type_id No int ID of the link type. Link types explained in Menu Link Type section.
title No 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: Update menu item success

Request headers

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

Request payload

{
  "menu_link_type_name" : "static_link",
  "title" : "Google Search",
  "resource_data" : "http:\\www.google.com",
  "slug" : "google"
}

Response payload

{
    "message": "UPDATE_MENU_ITEM_SUCCESS",
    "body": {
        "menu_item": {
            "id": 2,
            "lft": 3,
            "rgt": 4,
            "parent_id": null,
            "depth": 0,
            "menu_name": "admin_panel_menu",
            "menu_link_type_name": "static_link",
            "title": "Google Search",
            "resource_data": "http:\\\\www.google.com",
            "entry_data": null,
            "icon": null,
            "slug": "google",
            "link": "http:\\\\www.google.com",
            "has_children": false,
            "clickable": true,
            "menu": {
                "id": 2,
                "name": "test_menu",
                "title": "Test Menu",
                "max_depth": 5,
                "is_system": true,
                "description": "Some description"
            },
            "menu_link_type": {
                "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 item not found

Request headers

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

Request payload

{
  "menu_link_type_name" : "static_link",
  "title" : "Google Search",
  "resource_data" : "http:\\www.google.com",
  "slug" : "google"
}

Response payload

{
  "message": "MENU_ITEM_NOT_FOUND",
  "body": {
    "id": 15
  }
}

Delete a Menu Item

Deletes a menu item.

REQUEST

URL:

DELETE http://photoncms.test/api/menus/items/<ITEM_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Delete menu item success

Request headers

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

Response payload

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

Example: Menu item not found

Request headers

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

Response payload

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

Reposition a Menu Item

Repositions a menu item.

You can use an id or a slug to reference an item, or id or name to reference a menu.

REQUEST

URL:

PUT http://photoncms.test/api/menus/items/reposition

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Type Description
menu_id Yes int Id of the menu for moving items between menus.
action Yes string Name of the action which should be performed on the menu item.
affected_item_id Yes int Id of the affected menu item.
target_item_id Yes/No int Id of the target menu item if the case requires one. For example, when changing a menu, this would be an id of an item in that menu.

Available actions:

Action Required fields Description
moveLeft
  • action
  • affected_item_id
Find the left menu item and move to the left of it.
moveRight
  • action
  • affected_item_id
Find the right menu item and move to the right of it.
moveToLeftOf
  • action
  • affected_item_id
  • target_item_id
Move to the menu item to the left of …
moveToRightOf
  • action
  • affected_item_id
  • target_item_id
Move to the menu item to the right of …
makeNextSiblingOf
  • action
  • affected_item_id
  • target_item_id
Alias for moveToRightOf.
makeSiblingOf
  • action
  • affected_item_id
  • target_item_id
Alias for makeNextSiblingOf.
makePreviousSiblingOf
  • action
  • affected_item_id
  • target_item_id
Alias for moveToLeftOf.
makeChildOf
  • action
  • affected_item_id
  • target_item_id
Make the menu item a child of …
makeFirstChildOf
  • action
  • affected_item_id
  • target_item_id
Make the menu item the first child of …
makeLastChildOf
  • action
  • affected_item_id
  • target_item_id
Alias for makeChildOf.
makeRoot
  • action
  • affected_item_id
Make current menu item a root menu item.
setScope
  • menu_id
  • action
  • affected_item_id
Moves the menu item to another menu. In this case target_item_id represents a name or Id of a future parent item in the targeted menu.

Example: Reposition menu item success

Request headers

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

Request payload

{
  "action" : "makeChildOf",
  "affected_item_id" : 4,
  "target_item_id" : 1
}

Response payload

{
    "message": "REPOSITION_NODE_SUCCESS",
    "body": {
        "affected_node": {
            "id": 4,
            "lft": 2,
            "rgt": 3,
            "parent_id": 1,
            "depth": 1,
            "menu_name": "admin_panel_menu",
            "menu_link_type_name": "static_link",
            "title": "User 1",
            "resource_data": "\"user1url\"",
            "entry_data": null,
            "icon": null,
            "slug": null,
            "link": "\"user1url\"",
            "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": 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: Move menu item to another menu

Request headers

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

Request payload

{
  "action" : "setScope",
  "affected_item_id" : 4,
  "menu_id" : 2
}

Response payload

{
  "message": "REPOSITION_NODE_SUCCESS",
  "body": {
    "affected_node": {
      "id": 4,
      "lft": 5,
      "rgt": 6,
      "parent_id": null,
      "depth": 0,
      "menu_name": "test_menu",
      "menu_link_type_name": "static_link",
      "title": "User 1",
      "resource_data": "\"user1url\"",
      "entry_data": null,
      "icon": null,
      "slug": null,
      "link": "\"user1url\"",
      "has_children": false,
      "clickable": true,
      "menu": {
        "id": 2,
        "name": "test_menu",
        "title": "Test Menu",
        "max_depth": 5,
        "is_system": true,
        "description": "Some description"
      },
      "menu_link_type": {
        "id": 2,
        "name": "static_link",
        "title": "Static Link",
        "clickable": true,
        "is_system": true,
        "has_generic_icon": false
      }
    }
  }
}

Example: Affected menu item not found

Request headers

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

Request payload

{
  "action" : "makeChildOf",
  "affected_item_id" : 50,
  "menu_id" : 2
}

Response payload

{
  "message": "MENU_ITEM_NOT_FOUND",
  "body": {
    "affected_item_id": "50"
  }
}

Example: Target menu item not found

Request headers

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

Request payload

{
  "action" : "makeChildOf",
  "affected_item_id" : 4,
  "target_item_id" : 50
}

Response payload

{
  "message": "MENU_ITEM_NOT_FOUND",
  "body": {
    "target_item_id": "50"
  }
}

Example: Menu not found

Request headers

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

Request payload

{
  "action" : "makeChildOf",
  "affected_item_id" : 4,
  "menu_id" : 20
}

Response payload

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

Example: Trying to move a menu item within itself

Request headers

PUT /api/menus/items/reposition HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 500 Internal Server Error

Request payload

{
  "action" : "makeChildOf",
  "affected_item_id" : 4,
  "target_item_id" : 4
}

Response payload

{
  "message": "PHP_NATIVE_EXCEPTION",
  "body": {
    "message": "A node cannot be moved to a descendant of itself (inside moved tree).",
    "code": 0,
    "file": "C:\\wamp64\\www\\OHD\\photoncms\\vendor\\baum\\baum\\src\\Baum\\Move.php",
    "line": 215
  }
}


This example shows what happens when you try to affect an item with itself. This case is especially when trying to set one item as its own child, but the logic is the same if you send the same id or slug for the affected and target items.

Menu Link Type

This section deals with menu link types.

Menu link type main purpose is dealing with the actual link to the menu item. Menu link type knows how to parse a menu item resource and compile a link for it.

Retrieves available menu link types.

Photon comes with some predefined link types, but this is extendible and shouldn’t be hard coded. Always use this route to fetch the current list of menu link types.

REQUEST

URL:

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

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Request headers

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

Response payload

{
  "message": "LOAD_MENU_LINK_TYPES_SUCCESS",
  "body": {
    "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
      },
      {
        "id": 3,
        "name": "menu_item_group",
        "title": "Menu Item Group",
        "clickable": false,
        "is_system": true,
        "has_generic_icon": false
      },
      {
        "id": 4,
        "name": "admin_panel_single_entry",
        "title": "Admin Panel Single Entry",
        "clickable": true,
        "is_system": true,
        "has_generic_icon": true
      }
    ]
  }
}
ID Menu link type resource_data entry_data
1 admin_panel_module_link JSON encoded data about module that should be used for specific menu item Not required
2 static_link URL Not required
3 menu_item_group Not required Not required
4 admin_panel_single_entry JSON encoded data about module that should be used for specific menu item JSON encoded data about selected individual entry from module specified within resource_data

Nodes

This section deals with nodes.

Get Nodes

Retrieves a list of nodes for a given table name. The result will contain only root nodes for the given module.

REQUEST

URL:

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

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Get nodes success

Request headers

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

Response payload

{
  "message": "LOAD_NODE_SUCCESS",
  "body": {
    "children": [
      {
        "id": 1,
        "anchor_text": "Album: Another World",
        "table_name": "albums",
        "has_children": true
      },
      {
        "id": 2,
        "anchor_text": "Album: Trust in Trance",
        "table_name": "albums",
        "has_children": true
      }
    ]
  }
}

Example: Module not found

Request headers

GET /api/nodes/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"
  }
}

Get Node Children

Retrieves node’s immediate or scoped children.

REQUEST

URL:

GET http://photoncms.test/api/nodes/<TABLE_NAME>/<ITEM_ID>[?child_modules[]=...&child_modules[]=...]

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
child_modules No array An array of table names from which data is expected.

Example: Get children success

Request headers

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

Response payload

{
  "message": "LOAD_NODE_SUCCESS",
  "body": {
    "children": [
      {
        "id": 3,
        "anchor_text": "Album: Extras",
        "table_name": "albums",
        "has_children": true
      },
      {
        "id": 5,
        "anchor_text": "Song: Nilaya",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 6,
        "anchor_text": "Song: Another World",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 7,
        "anchor_text": "Song: Visions of Nasca",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 8,
        "anchor_text": "Song: Searching for UFO's",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 9,
        "anchor_text": "Song: Tryptomine Dream",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 1,
        "anchor_text": "Lyric: Nilaya",
        "table_name": "lyrics",
        "has_children": false
      }
    ]
  }
}

Example: Get children from specific table success

Request headers

GET /api/nodes/albums/1?child_modules[]=songs HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "LOAD_NODE_SUCCESS",
  "body": {
    "nodes": [
      {
        "id": 3,
        "anchor_text": "Album: Extras",
        "table_name": "albums",
        "has_children": true
      },
      {
        "id": 5,
        "anchor_text": "Song: Nilaya",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 6,
        "anchor_text": "Song: Another World",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 7,
        "anchor_text": "Song: Visions of Nasca",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 8,
        "anchor_text": "Song: Searching for UFO's",
        "table_name": "songs",
        "has_children": false
      },
      {
        "id": 9,
        "anchor_text": "Song: Tryptomine Dream",
        "table_name": "songs",
        "has_children": false
      }
    ]
  }
}

Example: Entry not found

Request headers

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

Response payload

{
  "message": "NODE_NOT_FOUND",
  "body": {
    "node_id": "50"
  }
}

Example: Module not found

Request headers

GET /api/nodes/wrong_module/1 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"
  }
}

Get Node Ancestors

Retrieves node ancestors. Ancestors can be direct module predecessors, or scoped ones.

REQUEST

URL:

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

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Get ancestors success

Request headers

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

Response payload

{
  "message": "LOAD_NODE_ANCESTORS_SUCCESS",
  "body": {
    "ancestors": [
      {
        "id": 1,
        "table_name": "artists"
      },
      {
        "id": 1,
        "table_name": "genres"
      }
    ]
  }
}

Example: Entry not found

Request headers

GET /api/nodes/albums/ancestors/50 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 404 Not Found

Response payload

{
  "message": "NODE_NOT_FOUND",
  "body": {
    "node_id": "50"
  }
}

Example: Module not found

Request headers

GET /api/nodes/wrong_module/ancestors/1 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"
  }
}

Reposition Node

Repositions a node according to the specified criteria.

Depending on the module type, nodes will behave differently:

REQUEST

URL:

PUT http://photoncms.test/api/nodes/reposition

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

PAYLOAD:

Parameter Required Value Description
action Yes string Name of the action which should be performed on the node.
affected[table_name] Yes string Table name of the affected node.
affected[id] Yes int Id of the affected node.
target[id] Yes/No int Id of the target node if the case requires one. For example, when changing a scope, this would be an id of the scope item.

Available actions:

Action Required fields Description
moveLeft
  • action
  • affected[table]
  • affected[id]
Find the left sibling and move to the left of it.
moveRight
  • action
  • affected[table]
  • affected[id]
Find the right sibling and move to the right of it.
moveToLeftOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Move to the node to the left of …
moveToRightOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Move to the node to the right of …
makeNextSiblingOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Alias for moveToRightOf.
makeSiblingOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Alias for makeNextSiblingOf.
makePreviousSiblingOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Alias for moveToLeftOf.
makeChildOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Make the node a child of …
makeFirstChildOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Make the node the first child of …
makeLastChildOf
  • action
  • affected[table]
  • affected[id]
  • target[id]
Alias for makeChildOf.
makeRoot
  • action
  • affected[table]
  • affected[id]
Make current node a root node.
setScope
  • action
  • affected[table]
  • affected[id]
  • target[id]
Sets the scope of the current node (used for hierarchical classification).
unsetScope
  • action
  • affected[table]
  • affected[id]
Clears the scope of the current node (used for hierarchical classification).

Example: Change node scope success

Request headers

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

Request payload

{
  "action" : "setScope",
  "affected" : {
    "table" : "songs",
    "id" : 9
  },
  "target" : {
    "id" : 2
  }
}

Response payload

{
  "message": "REPOSITION_NODE_SUCCESS",
  "body": {
    "affected_node": {
      "id": 9,
      "lft": 9,
      "rgt": 10,
      "parent_id": null,
      "depth": 0,
      "scope_id": 2,
      "created_at": "2016-06-28T08:54:56+00:00",
      "updated_at": "2017-05-09T10:46:23+00:00",
      "anchor_text": "Song: Tryptomine Dream",
      "name": "Tryptomine Dream",
      "permission_control": {
        "edit_restrictions": [],
        "crud": {
          "create": true,
          "update": true,
          "delete": true
        }
      },
      "extensions": null
    }
  }
}

Example: Affected node not found

Request headers

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

Request payload

{
  "action" : "setScope",
  "affected" : {
    "table" : "songs",
    "id" : 80
  },
  "target" : {
    "id" : 5
  }
}

Response payload

{
  "message": "AFFECTED_NODE_NOT_FOUND",
  "body": {
    "id": "80"
  }
}


In this situation both the affected and target IDs are invalid, but the API checks and fails on the first parameter before the second one is checked. So this case doesn’t necessarily say that the target ID is valid.

Example: Scope node not found

Request headers

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

Request payload

{
  "action" : "setScope",
  "affected" : {
    "table" : "songs",
    "id" : 9
  },
  "target" : {
    "id" : 5
  }
}

Response payload

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

Example: Target node not found

Request headers

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

Request payload

{
  "action" : "makeNextSiblingOf",
  "affected" : {
    "table" : "songs",
    "id" : 9
  },
  "target" : {
    "id" : 80
  }
}

Response payload

{
  "message": "TARGET_NODE_NOT_FOUND",
  "body": {
    "id": "80"
  }
}

Example: Invalid action

Request headers

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

Request payload

{
  "action" : "invalidAction",
  "affected" : {
    "table" : "songs",
    "id" : 9
  },
  "target" : {
    "id" : 2
  }
}

Response payload

{
  "message": "INVALID_NODE_ACTION",
  "body": {
    "action": "invalidAction"
  }
}

Example: Scope module not found

Request headers

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

Request payload

{
  "action" : "setScope",
  "affected" : {
    "table" : "genres",
    "id" : 2
  },
  "target" : {
    "id" : 1
  }
}

Response payload

{
  "message": "SCOPE_MODULE_NOT_FOUND",
  "body": {
    "module_id": null
  }
}

This is the case when a setScope action is performed over a non-scoped module.

Example: Module Not found

Request headers

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

Request payload

{
  "action" : "makeNextSiblingOf",
  "affected" : {
    "table" : "wrong_table",
    "id" : 9
  },
  "target" : {
    "id" : 2
  }
}

Response payload

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

Photon

This section covers all internal photon routes.

Hard Reset

This functionality resets the photon installation to an initial state. All modules (including their models, migrations, seeds etc.), all data, all additional files, exporters, field types etc.. will be reverted to an initial photon distribution.

This functionality is protected in two ways (both requirements must be met):

REQUEST

URL:

GET http://photoncms.test/api/photon/hard_reset

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Hard reset success

Request headers

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

Response payload

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

Soft Reset

This functionality performs identical operations as Hard Reset, except that it doesn’t delete existing module extenders. The core extenders will be rebuilt anyway.

This functionality is protected in two ways (both requirements must be met):

REQUEST

URL:

GET http://photoncms.test/api/photon/soft_reset

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Soft reset success

Request headers

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

Response payload

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

Rebuild Module Model

This function will rebuild a module model according to the current module setup.

This is useful if you have changed the module manually for testing or any other reason.

REQUEST

URL:

GET http://photoncms.test/api/photon/rebuild_model/<MODULE_TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Rebuild module model success

Request headers

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

Response payload

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

Example: Module doesn’t exist

Request headers

GET /api/photon/rebuild_model/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"
  }
}

Rebuild Module Extender

This function will rebuild a module extender according to the current module setup.

This is useful if you have changed the module extender manually for testing or any other reason, or you have accidentally deleted it.

REQUEST

URL:

GET http://photoncms.test/api/photon/rebuild_extender/<MODULE_TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Rebuild module extender success

Request headers

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

Response payload

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

Example: Module doesn’t exist

Request headers

GET /api/photon/rebuild_extender/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"
  }
}

Sync

Sync is used to synchronize a photon installation after some new code has been pulled into the current installation from an SCM.

An example workflow is following:

A developer works on a local installation. After the work is done, it is pushed to the SCM. Another developer pulls the code. After the code was successfully pulled, a sync call is performed to synchronize the second installation with the version which was pulled.

If the sync fails, you can have a qualified person inspect the error. An error could occur if someone has manually worked on the DB or perhaps some incoming seeds from the SCM do not comply in structure to the local DB.

REQUEST

URL:

GET http://photoncms.test/api/photon/sync

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Sync success

Request headers

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

Response payload

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

Revert to Sync

This will revert the current installation to the state after the last sync was performed. It will affect modules and their data.

REQUEST

URL:

GET http://photoncms.test/api/photon/revert_to_sync

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Rebuild module success

Request headers

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

Response payload

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

Revert Module to Sync

This will revert the specified module to the state after the last sync was performed. It will affect the module and its data.

REQUEST

URL:

GET http://photoncms.test/api/photon/revert_to_sync/<MODULE_TABLE_NAME>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Rebuild module success

Request headers

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

Response payload

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

Example: Module doesn’t exist

Request headers

GET /api/photon/revert_to_sync/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"
  }
}

Notifications

This section explains manipulating with notifications within Photon, and ways in which they can be extended to accommodate system requirements.

Send Notification

Photon notifications can be sent in many ways. Following are some currently available notifications in Photon and channels through which they are sent:

Name Ways of sending Description
EmailChangeConfirmation
  • mail
Sends a confirmation email to change the current email address (sent through the system, while logged in, to the new email address).
EmailChangeSuccess
  • mail
Notifies the user of the successful email change.
InvitationIssued
  • mail
Notifies a future user with an invitation email to register.
NewUserRegistered
  • mail
  • broadcast
  • database
Notifies system administrators that a new user has registered.
RegistrationConfirmation
  • mail
Sends a confirmation email for registration.
RegistrationSuccess
  • mail
Notifies the user about successful registration.
ResetPassword
  • mail
Notifies the user of a successful password change.
UserSubscribed
  • broadcast
  • database
Notifies the user when another user subscribes to dynamic module entry that he is currently subscribed to.
UserUnsubscribed
  • broadcast
  • database
Notifies the user when another user unsubscribes from dynamic module entry that he is currently subscribed to.

Currently, there are 4 notification channels available:

Notifications can be extended or created using these channels.

For database notifications, you need to set the NOTIFICATION_SERVICE_EMAIL value in .env. This will tell the application which email address to use to sign emails.

REQUEST

URL:

POST http://photoncms.test/api/notify/<NOTIFICATION_NAME>

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Payload parameters are dynamic and depend on the implementation of a specific notification. Currently implemented notifications are handled by the system, so they have the input automated. But if any new notifications are made and used through this route, any POST parameters sent will be available within the notification notify($data) method.

Example: Notification sent

Request headers

POST /api/notify/world_destruction HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{}

Response payload

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

Example: Notification doesn’t exist

Request headers

POST /api/notify/wrong_notification HTTP/1.1
Accept: application/json
Status: 404 Not Found

Request payload

{}

Response payload

{
  "message": "NOTIFICATION_HELPER_DOESNT_EXIST",
  "body": {
    "notification_name": "wrong_notification"
  }
}

Mark as Read

Marks a notification as read.

This route deals with notifications through the database channel.

REQUEST

URL:

GET http://photoncms.test/api/notifications/read/<NOTIFICATION_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Notification read successfully

Request headers

GET /api/notifications/read/8b2d915d-9fd2-4b02-89b1-1790090150d0 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

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

Example: Notification doesn’t exist

Request headers

GET /api/notifications/read/53f12f6c-809a-40da-96c5-bfc3d9d4bdb8 HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

{
  "message": "NOTIFICATION_NOT_FOUND",
  "body": {
    "notification_id": "53f12f6c-809a-40da-96c5-bfc3d9d4bdb8"
  }
}

Count Unread

Counts unread notifications for the current user.

This route deals with notifications through the database channel.

REQUEST

URL:

GET http://photoncms.test/api/notifications/unread/count

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Unread notification count

Request headers

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

Response payload

{
  "message": "GET_UNREAD_NOTIFICATIONS_COUNT_SUCCESS",
  "body": {
    "count": 0
  }
}

Retrieve Notifications

Retrieves all notifications for the current user. Pagination is implemented.

This route deals with notifications through the database channel.

REQUEST

URL:

POST http://photoncms.test/api/notifications/all

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Parameter Required Value Description
pagination[items_per_page] No int Maximum number of items per response.
pagination[current_page] No int Current page of items.

Example: Notification sent

Request headers

POST /api/notifications/all HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{
  "pagination" : {
    "items_per_page" : 3,
    "current_page" : 2
  }
}

Response payload

{
  "message": "NOTIFICATIONS",
  "body": {
    "notifications": [
      {
        "id": "53f12f6c-809a-40da-96c5-bfc3d9d4bdb8",
        "type": "NewUserRegistered",
        "read_at": "2016-11-29T11:37:47+0000",
        "created_at": "2016-11-29T11:29:05+0000",
        "subject": "New user registered",
        "compiled_message": "John Doe just successfully registered!"
      }
    ],
    "pagination": {
      "total": 1,
      "count": 1,
      "current_page": 1,
      "has_more_pages": false,
      "last_page": 1,
      "per_page": 3
    }
  }
}

Retrieve Unread Notifications

Retrieves unread notifications for the current user.

This route deals with notifications through the database channel.

REQUEST

URL:

POST http://photoncms.test/api/notifications/unread

HEADERS:

Parameter Value
Accept application/json

PAYLOAD:

Parameter Required Value Description
pagination[items_per_page] No int Maximum number of items per response.
pagination[current_page] No int Current page of items.

Example: Notification sent

Request headers

POST /api/notifications/unread HTTP/1.1
Accept: application/json
Status: 200 OK

Request payload

{
  "pagination" : {
    "items_per_page" : 3,
    "current_page" : 2
  }
}

Response payload

{
  "message": "GET_UNREAD_NOTIFICATIONS_SUCCESS",
  "body": {
    "notifications": [
      {
        "id": "53f12f6c-809a-40da-96c5-bfc3d9d4bdb8",
        "type": "NewUserRegistered",
        "read_at": null,
        "created_at": "2016-11-29T11:29:05+0000",
        "subject": "New user registered",
        "compiled_message": "John Doe just successfully registered!"
      }
    ],
    "pagination": {
      "total": 1,
      "count": 1,
      "current_page": 1,
      "has_more_pages": false,
      "last_page": 1,
      "per_page": 3
    }
  }
}

Assign FCM Token

Assigns an FCM token that the application will use for sending push notifications.

REQUEST

URL:

GET http://photoncms.test/api/notifications/fcm/assign_token/<FCM_TOKEN>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Token assigned successfully

Request headers

GET /http://photoncms.test/api/notifications/fcm/assign_token/<FCM_TOKEN> HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

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

Revoke FCM Token

Assigns an FCM token that the application will use for sending push notifications.

REQUEST

URL:

GET http://photoncms.test/api/notifications/fcm/revoke_token/<FCM_TOKEN>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Token revoked successfully

Request headers

GET /http://photoncms.test/api/notifications/fcm/revoke_token/<FCM_TOKEN> HTTP/1.1
Accept: application/json
Authorization: Bearer <API_TOKEN>
Status: 200 OK

Response payload

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

Subscription

This section explains how user can subscribe and unsubscribe to individual dynamic module entry.

Subscribe

Subscribe currently logged in user to individual dynamic module entry. As a response list of all other subscribed users is returned.

REQUEST

URL:

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

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful subscription

Request headers

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

Response payload

{
    "message": "SUBSCRIPTION_SUCCESS",
    "body": {
        "listOfSubscribedUsers": [
            {
                "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
            }
        ]
    }
}

Unsubscribe

Unsubscribe currently logged in user from individual dynamic module entry. As a response list of all remaining subscribed users is returned.

REQUEST

URL:

DELETE http://photoncms.test/api/subscribe/<TABLE_NAME>/<ITEM_ID>

HEADERS:

Parameter Value
Accept application/json
Authorization Bearer <API_TOKEN>

Example: Successful subscription

Request headers

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

Response payload

{
    "message": "UNSUBSCRIPTION_SUCCESS",
    "body": {
        "listOfSubscribedUsers": [
            {
                "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
            }
        ]
    }
}

Anchor Texts

Anchor texts are used to visually represent each entry. For example, for a user, it can be the user first and last name. Module anchor_text field can contain any text and also supports shortcodes for fields.

For example, if anchor text is User: {{first_name}} {{last_name}} that means that each entry within that module will have its anchor text compiled by inserting values from first_name and last_name columns of the respective entry. Like User: John Doe.

Many-to-one relations can also be used inside anchor_text field. In this case, the shortcode would be the name of the related table . name of the field. For example, if your relation is a field named ‘title’ in a table named ‘companies’, then your shortcode would be {{companies.title}}. An example of a whole anchor text of a user would be {{first_name}} {{last_name}}, {{companies.title}} and would render to something like John Doe, Photon CMS Inc..

Anchor texts are used by our native frontend for searching within entires of individual dynamic module. They can also be used within API filter route as any other module field.

Anchor Html

In case you need to implemenet advanced visual representation you can use anchor html. Within it you can store any html code together with shortcodes representing module fields, used in a same way as for anchor text.

If anchor html is defined it will be used for visual representation within our native frontend app. But anchor text will still be used by default for searching.

You can also define your custom method that would be used instead of shortcode representation of fields. In order to use it you need to define your own trait and use it within /app/PhotonCms/Core/Entities/DynamicModule/DynamicModuleHelpers.php. Custom method shortcode should be written in this format: {{argument1,argument2,...,argumentN|methodName}} where arguments are name of the fields. For example method shortcode {{width,height|max}} will call method max from your custom trait, pass fields width and height from individual dynamic module entry, determine which field is larger and print its value within anchor html.

Slug

You can define your own template which will be used to automatically generate URL valid name of any dynamic module entry.

It is defined using shortcodes in a same way like anchor text and anchor html, e.g. {{first_name}}-{{last_name}}. Major difference is that for slugs this shortcodes are only used on our fronted to generate suggestion for slug while you’re creating entry. User can freely modify that slug before saving it.

Cache

Photon has its own caching system implemented for all dynamically created modules. In order to use it you’ll need to enable it in .env file by adding variable USE_PHOTON_CACHING=1. All keys are by default cached for 60 minutes, and are automatically flushed if related entry is modified or deleted. You can change key lifespan by adding PHOTON_CACHING_TTL=60 variable.

Fields

This section explains all field types and how they are used.

There are some existing fields which come with a new Photon CMS installation. You can make your own field types if you wish.

Field attributes

Each field has attributes according to its purpose. Following is the list in alphabetic order of all available field attributes.

Name Type Required Direction Editable Default
can_create_search_choice boolean No R/W Yes false
column_name string Yes R/W No -
default mixed No R/W Yes null
disabled boolean No R/W Yes false
editable boolean No R/W Yes true
flatten_to_optgroups boolean No R/W Yes false
foreign_key mixed No R/W Yes automatic assignment if not supplied
hidden boolean No R/W Yes false
indexed boolean No R/W Yes false
is_default_search_choice boolean No R/W Yes false
is_system boolean No R/W Yes false
lazy_loading boolean No R/W Yes false
local_key mixed No R/W Yes automatic assignment if not supplied
module_id int - R No automatic assignment
name string Yes R/W Yes -
nullable boolean No R/W Yes false
order int - R Yes automatic assignment
pivot_table string No R/W No automatic assignment if not supplied
related_module string Yes R/W No -
relation_name string Yes R/W No -
is_active_entry_filter string No R/W Yes null
tooltip_text string No R/W Yes empty string
type int Yes R/W No -
validation_rules string No R/W Yes null
virtual boolean No R/W Yes false
virtual_name string Yes R/W Yes -

Attribute descriptions

Name Description
can_create_search_choice Use to determine if this field can trigger the creation of search choice from select2.js plugin.
column_name Name of the DB column for the field in snake_case notation.
default Sets the default parameter in the DB.
disabled Use this to determine if the field in the form should be disabled.
editable Use this to determine if the field in the form should be editable.
flatten_to_optgroups If set to true, select2.js plugin will flatten all entries fetched from multilevel sortable module, and use the root level as optgorups, and everything below as options.
foreign_key Custom foreign key in snake_case notation that will be used for relation. If the value is not provided, it will be auto-generated. In case of One to many field user must provide custom foreign_key in order for relation within module to be properly generated.
hidden Use this to determine if the field in the form should be hidden.
indexed Adds/removes the field indexing in the DB.
is_default_search_choice Use to determine which field should receive the data created via select2.js plugin.
is_system Use this to determine if the field in the form should be only read and assigned by the system.
lazy_loading Use this to determine if values should be lazy-loaded.
local_key Custom local key in snake_case notation that will be used for relation. If the value is not provided, it will be auto-generated.
module_id ID of the module to which the field belongs (this is automatically assigned and is a read-only value).
name Human readable field name.
nullable Sets the nullable parameter in the DB.
order Use this to order fields in a form (this is automatically assigned and is a read-only value).
pivot_table Name of the pivot table in snake_case notation (if the field represents a many-to-many relation). If the value is not provided, it will be auto-generated.
related_module ID of a related module (if the field represents a relation).
relation_name Name of the relation in snake_case notation (if the field represents a relation).
is_active_entry_filter Name of field from related module that is used for filtering search choices for select2.js plugin.
tooltip_text Text which should be used in front end to implement a popup over a field with field explanation.
type ID of the field type. Explained in the Field Types section.
validation_rules Validation rules written using Laravel validation notation.
virtual Determines if the field is virtual (in this case field data will never be stored in the database, but the value will be passed to the backend to be worked within a module extender).
virtual_name Name of the virtual field in snake_case notation (if the field is virtual).

Classifying field types into groups

All field types can be classified into 5 groups depending on their native purpose. Each group represents a collection of valid parameters for a field.

Regular field parameters

Name Type Required Direction Editable Default
column_name string Yes R/W No -
default mixed No R/W Yes null
disabled boolean No R/W Yes false
editable boolean No R/W Yes true
hidden boolean No R/W Yes false
indexed boolean No R/W Yes false
is_system boolean No R/W Yes false
lazy_loading boolean No R/W Yes false
module_id int - R No automatic assignment
name string Yes R/W Yes -
nullable boolean No R/W Yes false
order int - R Yes automatic assignment
tooltip_text string No R/W Yes empty string
type int Yes R/W No -
validation_rules string No R/W Yes null

One to many field parameters

Name Type Required Direction Editable Default
type int Yes R/W No -
can_create_search_choice boolean No R/W Yes false
is_active_entry_filter string No R/W Yes null
default mixed No R/W Yes null
disabled boolean No R/W Yes false
editable boolean No R/W Yes true
flatten_to_optgroups boolean No R/W Yes false
foreign_key mixed No R/W Yes automatic assignment
hidden boolean No R/W Yes false
is_default_search_choice boolean No R/W Yes false
is_system boolean No R/W Yes false
lazy_loading boolean No R/W Yes false
local_key mixed No R/W Yes automatic assignment
module_id int - R No automatic assignment
name string Yes R/W Yes -
order int - R Yes automatic assignment
related_module string Yes R/W No -
relation_name string Yes R/W No -
validation_rules string No R/W Yes null

Many to one field parameters

Name Type Required Direction Editable Default
can_create_search_choice boolean No R/W Yes false
is_active_entry_filter string No R/W Yes null
column_name string Yes R/W No -
default mixed No R/W Yes null
disabled boolean No R/W Yes false
editable boolean No R/W Yes true
flatten_to_optgroups boolean No R/W Yes false
foreign_key mixed No R/W Yes automatic assignment
hidden boolean No R/W Yes false
indexed boolean No R/W Yes false
is_default_search_choice boolean No R/W Yes false
is_system boolean No R/W Yes false
lazy_loading boolean No R/W Yes false
local_key mixed No R/W Yes automatic assignment
module_id int - R No automatic assignment
name string Yes R/W Yes -
nullable boolean No R/W Yes false
order int - R Yes automatic assignment
related_module string Yes R/W No -
relation_name string Yes R/W No -
tooltip_text string No R/W Yes empty string
type int Yes R/W No -

Many to many field parameters

Name Type Required Direction Editable Default
can_create_search_choice boolean No R/W Yes false
is_active_entry_filter string No R/W Yes null
disabled boolean No R/W Yes false
editable boolean No R/W Yes true
flatten_to_optgroups boolean No R/W Yes false
foreign_key mixed No R/W Yes automatic assignment
hidden boolean No R/W Yes false
is_default_search_choice boolean No R/W Yes false
is_system boolean No R/W Yes false
lazy_loading boolean No R/W Yes false
local_key mixed No R/W Yes automatic assignment
module_id int - R No automatic assignment
name string Yes R/W Yes -
order int - R Yes automatic assignment
pivot_table string No R/W No automatic assignment
related_module string Yes R/W No -
relation_name string Yes R/W No -
type int Yes R/W No -

Virtual field parameters

Name Type Required Direction Editable Default
disabled boolean No R/W Yes false
hidden boolean No R/W Yes false
is_system boolean No R/W Yes false
module_id int - R No automatic assignment
name string Yes R/W Yes -
order int - R Yes automatic assignment
tooltip_text string No R/W Yes empty string
type int Yes R/W No -
validation_rules string No R/W Yes null
virtual boolean No R/W Yes false
virtual_name string Yes R/W Yes -

Field types

There are default field types provided with photon installation. But to be sure always use Get field types to acquire all currently existing field types.

Default photon field types:

ID Type Title Laravel type Is system
1 input_text Input Text string No
2 rich_text Rich Text text No
3 image Image string No
4 boolean Boolean boolean No
5 date Date date No
7 many_to_one Many to One integer No
8 many_to_many Many to Many - No
9 password Password string No
10 integer Integer integer No
11 system_integer System Integer integer Yes
12 system_date_time System Date-time datetime Yes
13 system_string System String string Yes
14 one_to_one One to One int Yes
15 file File string No
16 files Files - No
17 one_to_many One To Many - No
18 date_time Date-time datetime No
19 gallery Gallery integer No
20 many_to_one_extended Many to One Extended integer No
21 many_to_many_extended Many to Many Extended - No
22 one_to_one_extended Many to Many Extended - No
23 one_to_many_extended One To Many Extended - No

Field type parameter explanation:

Name Type Description
ID int Id of the type in the DB
Type string System name of the field typewritten in snake_case notation
Title string Human readable title of the field type
Laravel type string Represents a type of the database field according to Available Column types section of Laravel migrations documentation.
Is system boolean Represents if the field value is system controlled

Exporters

Exporters export data to various formats. Photon is shipped with some predefined exporters, but you can also create your own.

Exporters are implemented in such a way that each module can have its exporter.

Custom exporters

Exporter classes are located in app/PhotonCms/Dependencies/ModuleExporters. Within this directory, each module can have its own set of exporters. Exporter classes for a module are made for each format you need (PDF, XLSX, CSV). Also, each export class can cover an export function for single and multiple entries of that module.

When you have created your custom exporter, scroll to Export Module Entry section or Export Module Entries section to check out how to use them.

Extensions

Each module, when generated, has its own model class made. This class will be located in app/PhotonCms/Dependencies/DynamicModels. But any time you update your module, the model class will be recompiled. This means that any changes you have made manually on the model class will be overwritten.

If you need to extend the module model class, you may do so by creating a module extension class.

Module extension classes are located in app/PhotonCms/Dependencies/ModuleExtensions. To create a module extender, create a class file with the name in the following convention: [name of the module - camel case notation]ModuleExtensions.php.

Each extension class has an automatic and manual methods section.

For a thoroughly explained example have a look at app\PhotonCms\Core\Entities\DynamicModuleExtension\BaseDynamicModuleExtension\DynamicModuleExtensionsExample.

Automatic methods

Following is a table of all available automatic methods which you can extend. They are called automatic because they are automatically called when a certain operation is performed over a module entry. This is also the only way to access these methods.

Method name Parameters Description
interruptCreate - Interrupts creation of a dynamic module entry.
interruptRetrieve &$entries Interrupts the retrieval of dynamic module entries.
interruptUpdate $entry Interrupts update of a dynamic module entry.
interruptDelete $entry Interrupts deletion of a dynamic module entry.
postCreate $item, $cloneAfter Executed after an entry has been persisted.
postRetrieve $item Executed after an entry has been persisted.
postUpdate $item, $cloneBefore, $cloneAfter Executed after an entry has been updated.
postDelete $item Executed after an entry has been deleted.
preCreate $item, $cloneAfter Executed before an entry has been persisted.
preRetrieve - Executed before an entry has been persisted.
preUpdate $item, $cloneBefore, $cloneAfter Executed before an entry has been updated.
preDelete $item, $cloneBefore Executed before an entry has been deleted.
executeGetterExtension $entry Provides an ability to add extension code to the dynamic module getAll() getter.
executeSetterExtension $entry Provides an ability to add extension code to the dynamic module setAll() setter.
getExtensionFunctionCalls $item Retrieves compiled extended function calls.

To let Photon know that it should check for and execute any of the automatic methods you have implemented, you need to implement a specific interface for each automatic method you have implemented. Following table shows which interface is used for which method.

Namespace for any of these interfaces is Photon\PhotonCms\Core\Entities\DynamicModuleExtension\Contracts.

Method name Interface name
interruptCreate ModuleExtensionCanInterruptCreate
interruptRetrieve ModuleExtensionCanInterruptRetrieve
interruptUpdate ModuleExtensionCanInterruptUpdate
interruptDelete ModuleExtensionCanInterruptDelete
postCreate ModuleExtensionHandlesPostCreate
postRetrieve ModuleExtensionHandlesPostRetrieve
postUpdate ModuleExtensionHandlesPostUpdate
postDelete ModuleExtensionHandlesPostDelete
preCreate ModuleExtensionHandlesPreCreate
preRetrieve ModuleExtensionHandlesPreRetrieve
preUpdate ModuleExtensionHandlesPreUpdate
preDelete ModuleExtensionHandlesPreDelete
executeGetterExtension ModuleExtensionHasGetterExtension
executeSetterExtension ModuleExtensionHasSetterExtension
getExtensionFunctionCalls ModuleExtensionHasExtensionFunctions

You can throw a PhotonException from any of the methods to properly stop the script execution.

Manual methods

Manual methods are methods which can be called on a module entry through Photon HMVC. Assign a specific route using the extension prefix /api/extension_call/test_table/ for the route in getExtensionFunctionCalls automatic method. After this define your manual function and you can call it using the assigned route.

Errors

The Photon CMS API uses the following error codes:

Error Code Meaning
401 Unauthorized
403 Forbidden
404 Not Found
406 Not Acceptable - Validation Error
429 Too Many Requests
500 Internal Server Error
503 Service Unavailable