API v6
Query the Log using the API
These requests retrieve a list of log entries, ordered by date/time in descending order. Note that the user making the request must have the Admin or IT role. The returned data is the same as in the Log section in the web interface.
GET /log.json GET /log/search/urlencoded_string.json (see search operators below)
The responses from these requests are paginated and /count.json
, /page/num.json
and X-Page-Size
can be used. See the section on pagination for more information. Example: GET /log/page/2.json
If successful, the response code is 200 OK
with the results in the response body.
Example response body:
[ { "id": 510396, "date_time": "2024-10-30 10:12:32", "ip_address": "85.42.37.192", "user": { "id": 1570, "name": "Ferran Barba", "deleted": false }, "action": { "id": "view_user", "description": "View user" }, "related_password": { "id": 0, "name": "", "deleted": false }, "related_project": { "id": 0, "name": "", "deleted": false }, "additional_data": { "raw": "5258|Claire Wood", "ui": "user: <a href=\"http:\/\/localhost\/tpm_devel\/site\/index.php\/users\/view\/5258\">Claire Wood<\/a>" }, "origin": "web" }, { "id": 510392, "date_time": "2024-10-30 10:11:48", "ip_address": "85.42.37.192", "user": { "id": 1570, "name": "Ferran Barba", "deleted": false }, "action": { "id": "view_password", "description": "View password data" }, "related_password": { "id": 10063, "name": "CMS", "deleted": false }, "related_project": { "id": 1361, "name": "Awesome project", "deleted": false }, "additional_data": { "raw": "tab=data", "ui": "tab=data" }, "origin": "web" }, ... ]
Searching the log
You can search the log using various criteria with the search operators listed below. Combine operators by separating them with spaces, like this:
operator1:value1 operator2:value2
Note that you need to URL encode the string of search operators. For example, in PHP:
// Find log entries where password_id is 7 and action_id is password_shown $search_string = 'password_id:7 action_id:password_shown'; $search_string_urlencoded = urlencode($search_string); $request_url = 'https://YOUR_TPM_URL/index.php/api/v6/log/search/' . $search_string_urlencoded . '.json';
Search operators
Operator | Definition | Example |
---|---|---|
date:x | Where x = always, exact date (format: yyyy-mm-dd), today, yesterday, current_month, previous_month, current_year or previous_year Searches for log entries with dates that correspond to the values above. If this operator is used, the date_min and date_max operators cannot be used. |
date:2024-10-30 date:today |
date_min:yyyy-mm-dd | Searches for log entries with dates on or after the specified value. Together with date_max they allow filtering log entries within a specified date range. If this operator is used, the date operator cannot be used. |
date_min:2024-09-01 |
date_max:yyyy-mm-dd | Searches for log entries with dates on or before the specified value. Together with date_min they allow filtering log entries within a specified date range. If this operator is used, the date operator cannot be used. |
date_max:2024-09-30 |
user_id:int (>0) | Searches for log entries created by the specified user id. | user_id:1 |
user_name:string | Searches for log entries created by the specified user name (not username). The search uses wildcards, so, for example, user_name:ferran will find entries created by users such as "ferran barba" or "barba ferran test". |
user_name:ferran |
action_id:string | Searches for log entries corresponding to the specified action_id. You can find a list of all action_ids in this page: List of log actions. |
action_id:view_password |
password_id:int (>0) | Searches for log entries that affect the specified password id. | password_id:240 |
password_name:string | Searches for log entries that affect the specified password name. The search uses wildcards, so for example password_name:test will find entries for password names such as "test site" or "mysql test instance". |
password_name:test |
project_id:int (>0) | Searches for log entries that affect the specified project id. | project_id:345 |
project_name:string | Searches for log entries that affect the specified project name. The search uses wildcards, so for example project_name:test will find entries for project names such as "test customer" or "mysql test list". |
project_name:test |
ip_address:string | Searches for log entries created from clients in the specified ip address. The search uses wildcards, so for example ip_address:85 will find entries for ip addresses such as "192.168.85.8" or "85.42.37.192". |
ip_address:192.168 |
additional_data:string | Searches for log entries that have the specified additional data in the raw field. The search uses wildcards, so for example additional_data:test will find entries that have additional data "this is a test" or "testing". |
additional_data:test |
origin:x | Where x = all, web, api or ext. Searches for log entries originated from the specified value. |
origin:web |
Document changelog
Dec 19, 2024: | Document created |