Patchman

Portal API Reference

The Patchman Portal API allows you to modify and update resources that you would otherwise have managed through the web interface.

The Portal API is organized around REST and designed to have predictable, resource-oriented URLs. We use built-in HTTP features, such as HTTP authentication, methods and response codes, that are understood by many HTTP clients. JSON is returned whenever possible, including in all errors.

Additionally, we have created a online web interface that allows you to explore the API with point-and-click. This interface is available from /api/v1/. The API is only available for plans featuring API access.

The Python code examples below require the excellent Requests library. Of course you could also use the default urllib module.

Unless specified otherwise in this documentation, you can simply use the operations listed to the right to access and modify objects. Not all operations are available on all resources, especially regarding which fields can be modified and which objects can be deleted. Searching is available in on a subset of fields (specified per resource) and only supports exact matches. Filters can be combined conjunctively.

In the case your client does not support e.g. PATCH or DELETE, you can:

  • Add the _method field to your POST request.
  • Add the X-HTTP-Method-Override header to your POST request.

All code examples below assume you are requesting JSON data (which is at this time the only accepted format).

HTTP methods

In a RESTful API, specific HTTP methods are used for specific actions.

GET
Retrieve all resources in a collection or a single resource.
POST
Create a new resource in a collection.
PUT
Update a resource by replacing it with the resource representation.
PATCH
Update a resource by replacing only specified resource attributes.
DELETE
Delete a resource.
Using PATCH versus PUT

When using PUT, you must specify a full resource representation as the request entity. Any properties that are omitted will be set to default values. Using PATCH will only update the resource with properties provided in the request entity.

Basic Operations

GET /api/v1/{RESOURCE}/ - retrieve a list of objects
GET /api/v1/{RESOURCE}/?{FIELD}={VALUE} - retrieve filtered list of objects
POST /api/v1/{RESOURCE}/ - create a new object
GET /api/v1/{RESOURCE}/{ID}/ - retrieve the object
PUT /api/v1/{RESOURCE}/{ID}/ - replace the object
PUT /api/v1/{RESOURCE}/{ID}/?{MODIFIER}={VALUE} - replace the object with modifiers
PATCH /api/v1/{RESOURCE}/{ID}/ - update the object
DELETE /api/v1/{RESOURCE}/{ID}/ - destroy the object

Ordering

Certain API end-points allow you to order their results by providing ordering GET parameter. The value should be a comma separated list of fields by which detections will be ordered. By default, the order is ascending, if descending order is desired, the field must be prefix by a "-" sign.

As of now, only detections allow sorting, every type of detections below describes the possible fields for ordering.

curl https://portal.patchman.co/api/v1/detections/applications/?ordering=application,-detected_at
import requests
requests.get("https://portal.patchman.co/api/v1/detections/applications/?ordering=application,-detected_at")
[
  {
    "url": "https://portal.patchman.co/api/v1/detections/applications/25432354/",
    "path": "/home/username/domains/domain-4.com/public_html/",
    "detected_at": "2021-01-01T12:00:00Z",
    "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
    "definition": {
      "id": 1,
      "application": "Application A",
      "version": "1.1",
      "up_to_date": true
    }
  },
  {
    "url": "https://portal.patchman.co/api/v1/detections/applications/484263/",
    "path": "/home/username/domains/domain-2.com/public_html/",
    "detected_at": "2018-01-01T12:00:00Z",
    "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
    "definition": {
      "id": 1,
      "application": "Application A",
      "version": "1.1",
      "up_to_date": true
    }
  },
  {
    "url": "https://portal.patchman.co/api/v1/detections/applications/484262/",
    "path": "/home/username/domains/domain-1.com/public_html/",
    "detected_at": "2020-01-01T12:00:00Z",
    "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
    "definition": {
      "id": 1,
      "application": "Application B",
      "version": "1.1",
      "up_to_date": true
    }
  },
  {
    "url": "https://portal.patchman.co/api/v1/detections/applications/25432358/",
    "path": "/home/username/domains/domain-3.com/public_html/",
    "detected_at": "2019-01-01T12:00:00Z",
    "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
    "definition": {
      "id": 1,
      "application": "Application B",
      "version": "1.1",
      "up_to_date": true
    }
  },
]

Suborganization filtering

The API's scope is by default limited to objects that fall directly under your organization's control. In contrast, the Portal webinterface does provide access to objects owned by suborganizations by default, so this may cause apparent differences between results shown in the webinterface and through the API. However, there's a filter option available for all objects that allows you to show results that fall under a particular suborganization. The filter field is suborganization and it accepts the ID of the suborganization.

Note that this filter is not available for the license key endpoint and suborganization endpoint, since those endpoints show suborganization results by default.

Example requests

GET /api/v1/{RESOURCE}/?suborganization={ID} - retrieve objects for suborganization
POST /api/v1/{RESOURCE}/?suborganization={ID} - create a new object for a suborganization
GET /api/v1/{RESOURCE}/{ID}/?suborganization={ID} - retrieve the object for a suborganization
PUT /api/v1/{RESOURCE}/{ID}/?suborganization={ID} - replace the object for a suborganization
PATCH /api/v1/{RESOURCE}/{ID}/?suborganization={ID} - update the object for a suborganization
DELETE /api/v1/{RESOURCE}/{ID}/?suborganization={ID} - destroy the object for a suborganization

Suspended account

In case your account is suspended, any request will give a HTTP 403 response and JSON from the example.

Example response

{
  "error": "Your account is suspended"
}

Authentication

The API is primarily accessible using OAuth2 Authorization Code and Client Credentials grants. Both flows require you to create an application in the 'Apps' section of your account in the Portal web interface.

The Authorization Code grant type is the one you should pick when you want others to authenticate through your app. This is a flow you may already know from other websites: the client logs in using his own credentials at the Portal web interface and accepts the application access.

The Client Credentials grant type is suited for situations where you are the only user of your application and you want to access your account details using an API.

If your application is not suited for use of any of these grant types, Implicit and Resource Owner Password Credentials (legacy) grants are also available. Please contact support detailing why you need these types if this is applicable to your situation.

OAuth2 Authorization Endpoint

https://portal.patchman.co/oauth2/authorize/

OAuth2 Token Endpoint

https://portal.patchman.co/oauth2/token/

Independent of the OAuth grant type, you will receive an access token that can be used to authorize your requests in the HTTP header. The token type will (almost) always be 'Bearer', which can be used to set the HTTP Authorization request header.

The latter of this section will describe how you can obtain such a token for the two supported grant types. The implementation of the Portal matches most common OAuth2 implementations and conforms to RFC 6749. You should be able to use most OAuth2 libraries to authenticate with the Portal. The documentation that follows is intended for those not comfortable using a dedicated OAuth2 library.

curl https://portal.patchman.co/api/v1/ \
  -H "Authorization: Bearer rBJVOkiV0Zv9O0B23HQwp4bgQVpyuB"
import requests
requests.get("https://portal.patchman.co/api/v1/",
             headers={'Authorization': 'Bearer rBJVOkiV0Zv9O0B23HQwp4bgQVpyuB'})

Authorization Code Grant Type

Authentication using authorization codes consists of the following steps:

  1. The flow is initiated by pointing the user's user agent (e.g. browser) to the authorization endpoint. This request includes the client identifier, requested scope, local state and a redirection URL.
    The user authenticates with the Portal and requests the user to accept or deny the requested access. Assuming the user has granted access, the Portal will redirect the user back to the redirection URL. This includes an authorization code and any local state provided by the client.
  2. The client requests an access token from the Portal's token endpoint, including the authorization code, client identifier, client secret and includes the redirection URL for verification.
    Finally, the Portal will verify the provided data and, assuming everything is correct, will issue an access token and optionally a refresh token.
Requesting Authorization

The first step in the authorization process is authentication of the user to the Portal and the authorization of the user for your application. This process starts by you, as client, redirecting the user to the authorization endpoint url, allowing you to provide the query parameters as specified below.

client_id:
string Your client ID you received through the Portal web interface.
redirect_uri:
optional string The URL in your app where users will be sent after authorization. This url must be identical to the URL you authorized in the Portal web interface.
scope:
optional string A space-separated list of scopes. If not provided, all scopes are requested by default. This behaviour is, however, subject to change and you are encouraged to request required scopes explicitly.
state:
optional string An unguessable random string. It is used to protect against cross-site request forgery attacks.

After authentication succeeds, the user is redirected to the redirect URI you specified before, with the code and state query parameters added to the URI. The provided authorization code is only valid for 60 seconds, requiring you to exchange the code for an access token.

Redirect the user to

https://portal.patchman.co/oauth2/authorize/
  ?response_type=code
  &client_id={CLIENT_ID}
  &state=some_random_string
  &scope=policy
  &redirect_uri=http://mysite.com

The user is redirected to

http://mysite.com
  ?code=x4cwG0Lz9dsFmyDpQip0rMT3FMatNY
  &state=some_random_string
Exchange for an Access Token

To exchange the authorization code received in the previous step for a more permanent access token, a POST request to the token endpoint should be made. This request is authorized using HTTP Basic authentication, using your client_id and client_secret as username and password (separated by a colon). Use the following POST parameters:

grant_type:
string Your grant type, which is authorization_code in this case.
code:
string The code you received as a response in step 1.
redirect_uri:
string The URI you redirected the user to in step 1.

The response (in JSON) includes the expiration time of the token, the granted scopes, and an access token and refresh token.

curl https://portal.patchman.co/oauth2/token/ \
  -u '{CLIENT_ID}:{CLIENT_SECRET}' \
  -d grant_type=authorization_code \
  -d code=x4cwG0Lz9dsFmyDpQip0rMT3FMatNY \
  -d 'redirect_uri=http://mysite.com'
requests.post("https://portal.patchman.co/oauth2/token/",
              auth=("{CLIENT_ID}", "{CLIENT_SECRET}"),
              data={"grant_type": "authorization_code",
                   "code": "x4cwG0Lz9dsFmyDpQip0rMT3FMatNY",
                   "redirect_uri": "http://mysite.com"})
{
  "expires_in": 36000,
  "scope": "policy",
  "access_token": "rBJVOkiV0Zv9O0B23HQwp4bgQVpyuB",
  "refresh_token": "5RrL9WqrwZ5rRHNT9tk1yxRqEDtU3z",
  "token_type": "Bearer"
}
Refresh a Token

As we have seen before, an access token can expire. You also receive a refresh token that can be used to obtain a new access token. After executing this action, the original access and refresh token can not be used to obtain access to the account anymore.

grant_type:
string Your grant type, which is refresh_token in this case.
refresh_token:
string The refresh token
curl https://portal.patchman.co/oauth2/token/ \
  -u '{CLIENT_ID}:{CLIENT_SECRET}' \
  -d grant_type=refresh_token \
  -d refresh_token=5RrL9WqrwZ5rRHNT9tk1yxRqEDtU3z
requests.post("https://portal.patchman.co/oauth2/token/",
              auth=("{CLIENT_ID}", "{CLIENT_SECRET}"),
              data={"grant_type": "refresh_token",
                    "refresh_token": "5RrL9WqrwZ5rRHNT9tk1yxRqEDtU3z"})
{
  "expires_in": 36000,
  "scope": "policy",
  "access_token": "75dhO6pzvRIpc4EbH9Tgz3bNIqgtfJ",
  "refresh_token": "Q5Bgj7K6lkbfnAcFNdUdqxdlSmUa0w",
  "token_type": "Bearer"
}

Client Credentials Grant Type

Authentication using client credentials is significantly easier to implement, as it only involves the client authenticating with the Portal and receiving an access token. You can directly exchange your client id and client secret for an access token for your own account:

grant_type:
string Your grant type, which is client_credentials in this case.
scope:
optional string A space-separated list of scopes. If not provided, all scopes are requested by default. This behaviour is, however, subject to change and you are encouraged to request required scopes explicitly.

The response (in JSON) includes the expiration time of the token, the granted scopes, and an access token and refresh token. The refresh token can be used in the same manner as with the authorization code grant type, although you could also simply reauthorize using the same method as described above.

curl https://portal.patchman.co/oauth2/token/ \
  -u '{CLIENT_ID}:{CLIENT_SECRET}' \
  -d grant_type=client_credentials
requests.post("https://portal.patchman.co/oauth2/token/",
        auth=("{CLIENT_ID}", "{CLIENT_SECRET}"),
        data={"grant_type": "client_credentials"})
{
  "expires_in": 36000,
  "scope": "policy",
  "access_token": "rBJVOkiV0Zv9O0B23HQwp4bgQVpyuB",
  "token_type": "Bearer"
}

License keys

License keys are used for registering new servers to your Portal account. They are used by the installation script, or used manually to enter in the /etc/patchman/license/key file prior to the agent's first start.

Note that after using the license key you will still need to approve the new server to your Portal account before it starts functioning completely. See server approval for more information.

License key objects

key:
read-only string The license key.
suborganization:
If your account has suborganizations, license keys for suborganizations are listed as well. This field specifies which suborganization a key belongs to. The key that belongs to your main organization will have a null value for this field.
{
  "url": "https://portal.patchman.co/api/v1/license-keys/1/",
  "key": "ARgnLtcLqQVU2dJ4pKG9NosXSvwOYWxYsTn07agqvjgjwbmtjyjWrhPjbAYMziN7dsMKowgstFTWcisht7JRd4wF1vxiYuo0Twpt"
  "suborganization": null,
}

License key revocation

If you think a license key may have been compromised, you can revoke it by performing a DELETE request to the license key object. A new license key will automatically be generated in its place, which you can request after the conclusion of the request. Since internally only the key property changes and the wrapping object isn't deleted in full, you will be able to request the new key using the same URL as the old one (the object isn't removed and the ID doesn't change).

Servers

Servers are objects representing your own hosting servers. They are part of a server group, which governs which default policies apply to the end-users of the server.

Server objects

id:
read-only integer The unique identifier for this object.
server_group:
read-only string The detail URI for the server group to which this server belongs.
hostname:
string The hostname of this server.
ip_address:
read-only string The IP address of this server.
domain_count:
read-only integer The total amount of domains on this server.
platform:
read-only string The control panel platform of this server. The platform determines how users are extracted from the server and the plug-in that is installed for your control panel. Valid values are plesk, directadmin and cpanel, or custom_files and custom_scripts when using a custom integration method.
end_users:
A list of all end-users of this server. This list only contains usernames and references to keep the list short.
This field can be hidden to limit the required processing time and response size. See below for more information.
url:
read-only url URI to follow for details on this end-user.
username:
read-only string Name of the end-user.
scan_time:
time optional This field shows the daily/weekly scan start time for the specific server. The time is shown in 24-hour format in UTC timezone, e.g. 13:45. The input is validated using the following regular expression: (2[0-3]|[01][0-9]):[0-5][0-9].

Note that this parameter does not control the schedule interval (hourly / daily / weekly), but rather allows to set the time when the scan task should start.
removable_per:
read-only datetime optional When the license is cancelled, at which moment will the server actually be removed. This depends on your plan settings and the current server status. If the server is not yet activated, this value will be null. If the server can be deleted without delay, the value will show the current date and time (and will thus depend on the time at which the request is performed).
removed_at:
read-only datetime optional If a license cancellation has been requested for this Server but it is currently still active, it's still included in the API details with this field set to its removal date. Note that after a server has been removed it is not visible to the API anymore; this field only serves to show impending removal, not past removals.

Search fields

approved:
string Filter servers based on their approval status. Unapproved servers are newly installed servers for which the license request hasn't yet been acknowledged. Valid values are true, false and all. The default value is true.
hostname:
string The hostname of the server.
ip_address:
string The IP address of the server.
server_group:
integer The server's group ID.
server_group_name:
string The server's group name.

Output control

end_users:
string Whether to show or hide related end-users. Accepts values show and hide, and defaults to show.

We encourage you to hide end-users when requesting a server list, to decrease processing time and output size. You can always request a list of related end-users by using the end-user API and filtering by server.
{
  "id": 1,
  "url": "https://portal.patchman.co/api/v1/servers/1/",
  "server_group": "https://portal.patchman.co/api/v1/servergroups/1/",
  "hostname": "localhost",
  "ip_address": "127.0.0.1",
  "domain_count": 3,
  "platform": "detect",
  "end_users": [
    {
      "url": "https://portal.patchman.co/api/v1/endusers/1/",
      "username": "admin"
    },
    {
      "url": "https://portal.patchman.co/api/v1/endusers/2/",
      "username": "enduser1234"
    }
  ],
  "scan_time": "15:46",
  "removable_per": "2016-01-01T00:00:00Z",
  "removed_at": null
}

Server license cancellation

To request the cancellation for a server, you can use the cancel action using a POST request. No content is required in the POST body. If the server can be removed immediately, this call will cancel the license and remove the server from your account. If the server can not be removed immediately, the license will be canceled and removed on the first allowed removal date. The removal date is determined by your plan's license period, and can be seen as the property removable_per on the server object.

You can only cancel a server that has been approved (i.e. is active) and has not yet been cancelled. For removing an unapproved server, please refer to this section.

POST https://portal.patchman.co/api/v1/servers/1/cancel/

Server approval

When a newly installed server contacts the Portal, it has to be approved before it will be fully activated and allowed to start scanning. You can approve a server using a POST request to the approve action on a Server object. During approval, you may change the hostname and server group of a server as well. Note that an unapproved server will always be created as a member of the default server group if you don't change this property before or during approval.

The action will not have any effect on an already approved server, even if you specify changes on the hostname and/or server group fields. Please use the regular server update method if you wish to change those properties after approval.

POST https://portal.patchman.co/api/v1/servers/1/approve/
{
  "server_group": "https://portal.patchman.co/api/v1/servergroups/1/",
  "hostname": "my.unapproved.server"
}

Removing unapproved servers

If a server creation request has been submitted for your account but you don't want to approve the server, you can delete it using the DELETE method on the server object in question (not the approve action).

Please note that deleting an unapproved server is not the same as cancelling the license for an approved and active server. That action is documented here. Performing this action on any server that has already been approved will be rejected.

DELETE https://portal.patchman.co/api/v1/servers/1/

Server Groups

A server group contains common settings for all servers that are part of the server group.

Server Group objects

id:
read-only integer The unique identifier for this object.
name:
string The name of this server group.
language_override:
optional string If specified, the language set by the control panel of the server is ignored and this language is used instead.
default_reseller_policy:
The default policy that is applied to all resellers of the servers, and all users below those resellers.
default_user_policy:
The default policy that is applied to the admin user and all users of the admin user

Fields below available only if the organization has enabled the custom platform integrations. If you do not use a standard panel automatically supported by Patchman, you can use the configuration options below to configure the integration parameters. Check the article for details.

platform:
Valid values are auto, custom_files and custom_scripts.
file_integration_user_data_path:
Directory on the server containing JSON files
file_integration_path_data_path
JSON file on the server
file_integration_user_changes_path
JSON file on the server
script_integration_user_data_path
Executable binary or shebang-qualified script on the server with JSON output
script_integration_path_data_path
Executable binary or shebang-qualified script on the server with JSON output
script_integration_user_changes_path
Executable binary or shebang-qualified script on the server with JSON output

Search fields

name:
string The server group name.

Modifiers

reapply_policies:
string When set to 'now', the policies will be reapplied for all users within all servers within this server group with task times scheduled relative to now. When set to 'detection', the policies will be reapplied with the task times scheduled relative to the original detection times.
{
  "id": 1,
  "url": "https://portal.patchman.co/api/v1/servergroups/1/",
  "name": "Default group",
  "language_override": "en",
  "default_reseller_policy": "https://portal.patchman.co/api/v1/policies/1/",
  "default_user_policy": "https://portal.patchman.co/api/v1/policies/1/",
  "platform": "auto",
  "file_integration_user_data_path": "",
  "file_integration_path_data_path": "",
  "file_integration_user_changes_path": "",
  "script_integration_user_data_path": "/etc/patchman/echo_details.sh",
  "script_integration_path_data_path": "/etc/patchman/echo.sh",
  "script_integration_user_changes_path": "/etc/patchman/echo_list.sh"
}

Policies

Policies are sets of rules that apply to end-users. Any end-user has only one applicable policy at a given time, and may be set explicitly on the end-user object, but also on one of its parent end-users or at the server level.

The availability of adding and changing policies depends on the plan of the organization.

Policy objects

name:
string The name of the policy.
notification_parent:
string The end-user that is notified in the case a notification has to be sent. See our knowledge base article for a full description of this setting. Valid settings are admin, reseller, user and descendant.
end_user_login:
string Indicates which end-users can login to the Patchman Portal. Valid settings are nobody, admin, reseller, user and descendant.
end_user_blocking:
string Indicates which end-users can block automatically scheduled actions. Valid settings are nobody, admin, reseller, user and descendant.
block_suspended:
boolean Indicates whether detections for suspended users should automatically be blocked.
allow_disabling_notifications:
boolean Indicates whether end-users have the option of disabling e-mail notifications themselves through the Portal interface.
allow_changing_email:
boolean Indicates whether end-users have the option to change their email address used for notifications themselves through the Portal interface.
audit_logging:
string Configures audit logfile creation on the server, and where these logfiles are kept. Can be set to none, centralized, homedir_own, homedir_parent, homedir_descendant.
audit_log_relative_path:
string The path of the audit logfile relative to the location specified through audit_logging. Not required if audit_logging is set to none or centralized.
audit_log_chown:
boolean Indicates whether the audit log file ownership is set to the applicable user.
email_from_name:
string The name in the From header of emails sent by this policy.
email_from_address:
string The email address in the Reply-To header of emails sent by this policy.
base_email_template_text:
read-only string The base email template for emails sent by this policy, formatted using Mustache. This field is displayed in your session's language. You can override this by passing ?lang={LANG} as query parameter.
base_email_template_html:
read-only string The base email template for emails sent by this policy in HTML, formatted using Mustache. This is also a localized field.
base_email_template:
read-only string A resource describing the base email template for emails sent by this policy.

Search fields

name:
string The policy name.
{
  "name": "Default Policy",
  "url": "https://portal.patchman.co/api/v1/policies/1/",
  "notification_parent": "admin",
  "end_user_login": "user",
  "end_user_blocking": "user",
  "block_suspended": true,
  "allow_disabling_notifications": true,
  "allow_changing_email": true,
  "audit_logging": "centralized",
  "audit_log_relative_path": "",
  "audit_log_chown": false,
  "email_from_name": "",
  "email_from_address": "no-reply@patchman.co",
  "base_email_template_text": "{{> content}}\r\n\r\n--\r\n{{> branding}}",
  "base_email_template_html": "<html></html>",
  "base_email_template": "https://portal.patchman.co/api/v1/policies-base-email-template/1/"
}

Policies Base Email Template

The policy base email templates are used as a base for formatting email messages sent to end-users.

Policy Base Email Template objects

languages:
array The supported email languages.
text_en:
string The English text base template.
text_es:
string The Spanish text base template.
text_da:
string The Danish text base template.
text_de:
string The German text base template.
text_fi:
string The Finnish text base template.
text_nl:
string The Dutch text base template.
text_fr:
string The French text base template.
text_ru:
string The Russian text base template.
text_uk:
string The Ukrainian text base template.
text_el:
string The Greek text base template.
text_it:
string The Italian text base template.
html_en:
string The English HTML base template.
html_es:
string The Spanish HTML base template.
html_da:
string The Danish HTML base template.
html_de:
string The German HTML base template.
html_fi:
string The Finnish HTML base template.
html_nl:
string The Dutch HTML base template.
html_fr:
string The French HTML base template.
html_ru:
string The Russian HTML base template.
html_uk:
string The Ukrainian HTML base template.
html_el:
string The Greek HTML base template.
html_it:
string The Italian HTML base template.
{
  "url": "https://portal.patchman.co/api/v1/policies-base-email-template/1/",
  "languages": [
    "en",
    "es",
    "da",
    "de",
    "fi",
    "nl",
    "fr",
    "ru",
    "uk",
    "el",
    "it",
  ],
  "text_en": "...",
  "text_es": "...",
  "text_da": "...",
  "text_de": "...",
  "text_fi": "...",
  "text_nl": "...",
  "text_fr": "...",
  "text_ru": "...",
  "text_uk": "...",
  "text_el": "...",
  "text_it": "...",
  "html_en": "...",
  "html_es": "...",
  "html_da": "...",
  "html_de": "...",
  "html_fi": "...",
  "html_nl": "...",
  "html_fr": "...",
  "html_ru": "...",
  "html_uk": "...",
  "html_el": "...",
  "html_it": "...",
}

End-users

End-users are accounts on your server.

End-user objects

id:
read-only integer The unique identifier for this object.
scan_url:
read-only Performing a POST request to this API URL will request a new scan for this user.
token_url:
read-only Performing a POST request to this API URL will request a login token for this user. This is similar to End-user Token Retrieval, but doesn't require client certificates to authenticate.
metrics_url:
read-only Performing a GET request to this API URL will obtain the number of detected malware, vulnerabilities and outdated applications for this user. See End-user Metrics for more information.
server:
read-only The server this is an end-user of.
parent:
read-only optional If any, the parent end-user of this end-user.
policy:
optional If any, the explicit policy set for this end-user.
effective_policy:
read-only The policy that is effective for this end-user. This value is retrieved by traversing the parent end-users (if any) as documented in our knowledge base article .
username:
read-only string The username of the end-user.
suspended:
read-only boolean Indicates whether the end-user is currently suspended.
level:
read-only string The level of the end-user, which can be one of admin, reseller or user.
language:
string The language of this end-user, which is used by email templates.
email:
string The email address of this end-user. This can contain multiple comma-separated email addresses.
language_frozen:
boolean If true, language updates sent from the server are ignored. You typically want to set this to true if you have manually overridden the end-user's language.
email_frozen:
boolean If true, email updates sent from the server are ignored. You typically want to set this to true if you have manually overridden the end-user's email address.
notifications_enabled:
boolean If false, no e-mail notifications will be sent regarding detections or actions for this end-user's account.
last_scan_at:
read-only optional datetime The time at which the user's last complete scan was completed.
last_scan_requested_at:
read-only optional datetime The time at which the user's last complete scan was requested (either manually or scheduled).

Search fields

username:
string The username of the end-user.
email:
string The e-mail address of the end-user.
parent:
integer The ID of the parent of the end-user.
parent_username:
string The username of the parent of the end-user.
server:
integer The ID of the server this end-user belongs to.
server_hostname:
string The hostname of the server this end-user belongs to (as registered in the Portal).
server_ip_address:
string The IP-address of the server this end-user belongs to.
suspended:
string The suspension status of the end-user. Valid values are true, false and all. The default value is all.

Modifiers

reapply_policy:
string When set to 'now', the effective policy will be reapplied with task times scheduled relative to now. When set to 'detection', the effective policy will be reapplied with the task times scheduled relative to the original detection times.
{
  "id": 1,
  "url": "https://portal.patchman.co/api/v1/endusers/1/",
  "scan_url": "https://portal.patchman.co/api/v1/endusers/1/scan/",
  "token_url": "https://portal.patchman.co/api/v1/endusers/1/token/",
  "metrics_url": "https://portal.patchman.co/api/v1/endusers/1/metrics/",
  "server": "https://portal.patchman.co/api/v1/servers/1/",
  "parent": null,
  "policy": null,
  "effective_policy": "https://portal.patchman.co/api/v1/policies/1/",
  "username": "admin",
  "suspended": false,
  "level": "admin",
  "language": "en",
  "email": "admin@localhost",
  "language_frozen": false,
  "email_frozen": false,
  "notifications_enabled": true,
  "last_scan_at": "2015-01-01T12:00:00Z",
  "last_scan_requested_at": "2015-01-01T11:00:00Z"
}

End-user Metrics

Obtains the number of resolved and unresolved detections for each of the three types: malware, vulnerabilities and outdated applications.

These counts reflect the number of results if you were to call Detections with an end-user filter.

End-user detection metrics objects

malware_unresolved:
integer Number of unresolved malware detections for the end-user.
malware_resolved:
integer Number of resolved malware detections for the end-user.
vulnerabilities_unresolved:
integer Number of unresolved vulnerabilities detections for the end-user.
vulnerabilities_resolved:
integer Number of resolved vulnerabilities detections for the end-user.
outdated_applications_unresolved:
integer Number of unresolved outdated application detections for the end-user.
outdated_applications_resolved:
integer Number of resolved outdated application detections for the end-user.
curl https://portal.patchman.co/api/v1/endusers/1/metrics/
import requests
requests.get("https://portal.patchman.co/api/v1/endusers/1/metrics/")
{
  "malware_unresolved": 1,
  "malware_resolved": 2,
  "outdated_applications_unresolved": 3,
  "outdated_applications_resolved": 4,
  "vulnerabilities_unresolved": 5,
  "vulnerabilities_resolved": 6
}

Detections

Patchman reports various kinds of detections. Each kind of detection has different parameters and supports different actions. Take care that you implement usage of these API resources separately.

All fields on detections and their associated actions are read-only. The only allowed modification is the creation of new actions for detections. Which actions are allowed depends on the type of detection, the current state of the detection, your policy settings and your plan.

Detections can be sorted by providing ordering GET parameter to the request. The value should be a comma separated list of fields by which detections will be ordered. By default the order is ascending, if descending order is desired, the field must be prefix by a "-" sign. Every detection end-point below gives a list of fields by which it can be ordered.

Applications

Application detections report the detected installations of web software packages. Only current detections are listed. Note that no actions are available for application detections.

Application detection objects

path:
read-only string The directory in which the application has been installed. Note that the installation may in reality be located in a subdirectory of the listed directory.
detected_at:
read-only datetime The time at which the installation was detected.
end_user:
The end-user to whom the installation directory belongs.
definition:
The details of which application version was detected, and whether or not the version is currently supported by its vendor.
id:
read-only integer The ID of the definition.
application:
read-only string The name of the application.
version:
read-only string The version of the application.
up_to_date:
read-only boolean If this version is supported by its vendor.

Search fields

end_user:
integer The ID of the end-user.
end_user_username:
string The username of the end-user.
server:
integer The ID of the server the end-user belongs to.
server_hostname:
string The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
string The IP-address of the server the end-user belongs to.
definition:
integer The ID of the definition the detection belongs to.
application:
string The name of the application the definition belongs to.
status:
string The status of the detection. Valid values are unresolved, resolved.
detected_before:
datetime Detected before the given time (exclusive), as an ISO 8601 timestamp.
detected_after:
datetime Detected after the given time (exclusive), as an ISO 8601 timestamp.

Sort fields

end_user:
The ID of the end-user.
end_user_username:
The username of the end-user.
server:
The ID of the server the end-user belongs to.
server_hostname:
The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
The IP-address of the server the end-user belongs to.
definition:
The ID of the definition the detection belongs to.
application:
The name of the application the definition belongs to.
status:
The status of the detection.
detected_at:
Time when the detection was made.
{
  "url": "https://portal.patchman.co/api/v1/detections/applications/1/",
  "path": "/home/username/domains/domain.com/public_html/",
  "detected_at": "2015-01-01T12:00:00Z",
  "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
  "definition": {
    "id": 1,
    "application": "Application",
    "version": "1.1",
    "up_to_date": true
  }
}

Malware

Malware detections list script files with malicious purposes. These malware detections are based on hash matching. No dynamic malware will be returned using this API endpoint.

Malware detection objects

actions:
The actions associated with this malware detection.
allowed_actions:
read-only string list The actions you can add for this detection in its current state.
path:
read-only string The file path of the detected file.
state:
read-only string The state of the detection. Valid values are waiting, resolved, blocked, retracted, reverted, error, pending_change and requires_attention.
detected_at:
read-only datetime The time at which the malware was detected.
resolution_scheduled_at:
read-only datetime optional The scheduled execution time of the earliest scheduled unexecuted resolution (quarantine or delete action), if applicable.
resolution_requested_at:
read-only datetime optional The request time of the earliest requested unexecuted resolution (quarantine or delete action), if applicable. An action is requested if the command was sent to the server and is pending completion.
resolution_reverted_at:
read-only datetime optional The completion time of the most recently executed reversal (undo_quarantine action), if applicable.
resolved_at:
read-only datetime optional The time at which the currently applicable resolution was completed, if the detection is currently listed as resolved and was not retracted.
retracted_at:
read-only datetime optional The time at which the currently applicable retraction was submitted, if the detection is currently listed as resolved and was retracted.
end_user:
read-only string URI to details of the end-user to whom the directory in which the file is located belongs.
definition:
The details of which form of malware was detected.
id:
read-only integer The ID of the malware definition.
name:
read-only string The name of the malware.
description:
read-only string Description of the malware.
type:
read-only string Type of malware.

Search fields

end_user:
integer The ID of the end-user.
end_user_username:
string The username of the end-user.
server:
integer The ID of the server the end-user belongs to.
server_hostname:
string The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
string The IP-address of the server the end-user belongs to.
definition:
integer The ID of the definition the detection belongs to.
status:
string The status of the detection. Valid values are unresolved, resolved.
detected_before:
datetime Detected before the given time (exclusive), as an ISO 8601 timestamp.
detected_after:
datetime Detected after the given time (exclusive), as an ISO 8601 timestamp.

Sort fields

end_user:
The ID of the end-user.
end_user_username:
The username of the end-user.
server:
The ID of the server the end-user belongs to.
server_hostname:
The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
The IP-address of the server the end-user belongs to.
definition:
The ID of the definition the detection belongs to.
status:
The status of the detection.
detected_at:
Time when the detection was made.
{
  "url": "https://portal.patchman.co/api/v1/detections/malware/1/",
  "actions": "https://portal.patchman.co/api/v1/detections/malware/1/actions/",
  "allowed_actions": [
    "quarantine",
    "block"
  ],
  "path": "/home/username/domains/domain.com/public_html/directory/file.php",
  "state": "waiting",
  "detected_at": "2015-01-01T12:00:00Z",
  "resolution_scheduled_at": "2015-01-15T12:00:00Z",
  "resolution_requested_at": null,
  "resolution_reverted_at": null,
  "resolved_at": null,
  "retracted_at": null,
  "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
  "definition": {
    "id": 1,
    "name": "shell.generic",
    "description": "Generic web shell",
    "type": "Web shell"
  }
}

Malware actions

Each malware detection has actions associated with it to denote the various changes that can be made to a file that was detected as malware. You cannot modify existing actions, but you are allowed to create new actions. These actions are for hash based detections. Actions submitted for dynamic malware to this endpoint will result in detection not found.

Malware action objects

type:
string The action type. Valid values (when reading) are detection, reminder, retraction, retraction_changed, retraction_deleted, retraction_definition_retracted, retraction_definition_superseded, quarantine, undo_quarantine, delete, block and unblock. When creating a new action, valid values are quarantine, undo_quarantine, delete, block and unblock (depending on the detection state and your plan).
scheduled_at:
read-only datetime optional The time for which execution of this action is scheduled, if applicable.
issued_at:
read-only datetime optional The time at which the command belonging to this action was sent to the server, if applicable.
failed_at:
read-only datetime optional The time at which the server reported it failed performing the requested action, if applicable.
completed_at:
read-only datetime optional The time at which the server reported it performed the requested action, if applicable.
notified_at:
read-only datetime optional The time at which an e-mail was sent to the end-user regarding this action, if applicable.
{
  "type": "detection",
  "scheduled_at": null,
  "issued_at": null,
  "failed_at": null,
  "completed_at": "2015-01-01T12:00:00Z",
  "notified_at": null
}

Dynamic malware

Dynamic malware detections list script files with malicious purposes. These malware detections are based on rules that match partial files. No hash based malware detections will be returned using this API endpoint.

Dynamic malware detection objects

actions:
The actions associated with this dynamic malware detection.
allowed_actions:
read-only string list The actions you can add for this detection in its current state.
path:
read-only string The file path of the detected file.
state:
read-only string The state of the detection. Valid values are waiting, resolved, blocked, retracted, reverted, error, pending_change and requires_attention.
detected_at:
read-only datetime The time at which the dynamic malware was detected.
resolution_scheduled_at:
read-only datetime optional The scheduled execution time of the earliest scheduled unexecuted resolution (quarantine or delete action), if applicable.
resolution_requested_at:
read-only datetime optional The request time of the earliest requested unexecuted resolution (quarantine or delete action), if applicable. An action is requested if the command was sent to the server and is pending completion.
resolution_reverted_at:
read-only datetime optional The completion time of the most recently executed reversal (undo_quarantine action), if applicable.
resolved_at:
read-only datetime optional The time at which the currently applicable resolution was completed, if the detection is currently listed as resolved and was not retracted.
retracted_at:
read-only datetime optional The time at which the currently applicable retraction was submitted, if the detection is currently listed as resolved and was retracted.
end_user:
read-only string URI to details of the end-user to whom the directory in which the file is located belongs.
definition:
The details of which form of dynamic malware was detected.
id:
read-only integer The ID of the malware definition.
name:
read-only string The name of the malware.
description:
read-only string Description of the malware.
type:
read-only string Type of malware.
file cleans:
List of details of the file clean operations performed for the detection.
id:
read-only integer The ID of the file clean operation.
performed_at:
read-only datetime Date when the file clean operation was performed.
before_hash:
read-only string MD5 hash of the affected file before the file clean operation was performed.
after_hash:
read-only string MD5 hash of the affected file after the file clean operation was performed.
deleted_at:
read-only datetime optional If and when the file clean operation was deleted by the client.
action:
read-only character Indicator if the file clean operation was a result of a manual action 'M' or an automatic action 'A'.

Search fields

end_user:
integer The ID of the end-user.
end_user_username:
string The username of the end-user.
server:
integer The ID of the server the end-user belongs to.
server_hostname:
string The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
string The IP-address of the server the end-user belongs to.
definition:
integer The ID of the definition the detection belongs to.
status:
string The status of the detection. Valid values are unresolved, resolved.
detected_before:
datetime Detected before the given time (exclusive), as an ISO 8601 timestamp.
detected_after:
datetime Detected after the given time (exclusive), as an ISO 8601 timestamp.

Sort fields

end_user:
The ID of the end-user.
end_user_username:
The username of the end-user.
server:
The ID of the server the end-user belongs to.
server_hostname:
The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
The IP-address of the server the end-user belongs to.
definition:
The ID of the definition the detection belongs to.
status:
The status of the detection.
detected_at:
Time when the detection was made.
{
  "url": "https://portal.patchman.co/api/v1/detections/dynamic-malware/1/",
  "actions": "https://portal.patchman.co/api/v1/detections/dynamic-malware/1/actions/",
  "allowed_actions": [
    "undo_clean",
  ],
  "path": "/home/username/domains/domain.com/public_html/directory/file.php",
  "state": "resolved",
  "detected_at": "2019-01-01T12:00:00Z",
  "resolution_scheduled_at": "2019-01-15T12:00:00Z",
  "resolution_requested_at": null,
  "resolution_reverted_at": null,
  "resolved_at": null,
  "retracted_at": null,
  "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
  "definition": {
    "id": 1,
    "name": "shell.generic.dynamic",
    "description": "Generic web shell",
    "type": "Web shell"
  },
  "file_cleans": [{
    "id": 1,
    "performed_at": "2019-01-02T17:00:00Z",
    "before_hash": "bb4870deb77e8993abe9c6a2925a93ed",
    "after_hash": "ad2e5352cc4abb6aa0b503974b6c5354",
    "deleted_at": null,
    "action": "A"
  }]
}

Dynamic malware actions

Each dynamic malware detection has actions associated with it to denote the various changes that can be made to a file that was detected as malware. You cannot modify existing actions, but you are allowed to create new actions. These malware detections are based on rules that match partial files. Actions submitted for hash based malware to this endpoint will result in detection not found.

Malware action objects

type:
string The action type. Valid values (when reading) are detection, reminder, retraction, retraction_changed, retraction_deleted, retraction_definition_retracted, retraction_definition_superseded, delete, block, unblock, clean and undo_clean. When creating a new action, valid values are unblock, clean and undo_clean(depending on the detection state and your plan).
file_clean:
When reading: Details of the file clean operation bound to the action. When writing: the ID of the file clean to revert when issuing a undo_clean action.
id:
read-only integer The ID of the file clean operation.
performed_at:
read-only datetime Date when the file clean operation was performed.
before_hash:
read-only string MD5 hash of the affected file before the file clean operation was performed.
after_hash:
read-only string MD5 hash of the affected file after the file clean operation was performed.
deleted_at:
read-only datetime optional If and when the file clean operation was deleted by the client.
action:
read-only character Indicator if the file clean operation was a result of a manual action 'M' or an automatic action 'A'.
scheduled_at:
read-only datetime optional The time for which execution of this action is scheduled, if applicable.
issued_at:
read-only datetime optional The time at which the command belonging to this action was sent to the server, if applicable.
failed_at:
read-only datetime optional The time at which the server reported it failed performing the requested action, if applicable.
completed_at:
read-only datetime optional The time at which the server reported it performed the requested action, if applicable.
notified_at:
read-only datetime optional The time at which an e-mail was sent to the end-user regarding this action, if applicable.

Example requests

curl https://portal.patchman.co/api/v1/detections/dynamic-malware/1/actions/ \
  -F type=undo_clean \
  -F file_clean=1
r = requests.post("https://portal.patchman.co/api/v1/detections/dynamic-malware/1/actions/",
                  data={"type": "undo_clean",
                        "file_clean": "1"})
{
  "type": "detection",
  "file_clean: {
    "id": 1,
    "performed_at": "2019-01-02T17:00:00Z",
    "before_hash": "bb4870deb77e8993abe9c6a2925a93ed",
    "after_hash": "ad2e5352cc4abb6aa0b503974b6c5354",
    "deleted_at": null,
    "action": "A"
  }
  "scheduled_at": null,
  "issued_at": null,
  "failed_at": null,
  "completed_at": "2015-01-01T12:00:00Z",
  "notified_at": null
}

Vulnerabilities

Vulnerability detections list files of installed web application software containing exploitable security vulnerabilities.

Vulnerability detection objects

actions:
The actions associated with this vulnerability detection.
allowed_actions:
read-only string list The actions you can add for this detection in its current state.
path:
read-only string The file path of the detected file.
state:
read-only string The state of the detection. Valid values are waiting, resolved, blocked, reverted, retracted and error.
detected_at:
read-only datetime The time at which the vulnerability was detected.
resolution_scheduled_at:
read-only datetime optional The scheduled execution time of the earliest scheduled unexecuted resolution (patch action), if applicable.
resolution_requested_at:
read-only datetime optional The request time of the earliest requested unexecuted resolution (patch action), if applicable. An action is requested if the command was sent to the server and is pending completion.
resolution_reverted_at:
read-only datetime optional The completion time of the most recently executed reversal (undo_patch action), if applicable.
resolved_at:
read-only datetime optional The time at which the currently applicable resolution was completed, if the detection is currently listed as resolved and was not retracted.
retracted_at:
read-only datetime optional The time at which the currently applicable retraction was submitted, if the detection is currently listed as resolved and was retracted.
end_user:
The end-user to whom the directory in which the file is located belongs.
definitions:
The definitions for the detected vulnerabilities. In case the file contains 1 vulnerability, this is a list containing one object. The vulnerability and type name will be translated based on the requested locale if a translation to the requested locale language is available.
id:
read-only integer The ID of the vulnerability definition.
name:
read-only string Name of the vulnerability.
description:
read-only string Description of the vulnerability.
type:
read-only string Type of the vulnerability.
application:
read-only string Name of the affected application.

Search fields

end_user:
integer The ID of the end-user.
end_user_username:
string The username of the end-user.
server:
integer The ID of the server the end-user belongs to.
server_hostname:
string The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
string The IP-address of the server the end-user belongs to.
definition:
integer The ID of the definition the detection belongs to.
application:
string The name of the application the definition belongs to.
status:
string The status of the detection. Valid values are unresolved, resolved.
detected_before:
datetime Detected before the given time (exclusive), as an ISO 8601 timestamp.
detected_after:
datetime Detected after the given time (exclusive), as an ISO 8601 timestamp.

Sort fields

end_user:
The ID of the end-user.
end_user_username:
The username of the end-user.
server:
The ID of the server the end-user belongs to.
server_hostname:
The hostname of the server the end-user belongs to (as registered in the Portal).
server_ip_address:
The IP-address of the server the end-user belongs to.
definition:
The ID of the definition the detection belongs to.
application:
The name of the application the definition belongs to.
status:
The status of the detection.
detected_at:
Time when the detection was made.
{
  "url": "https://portal.patchman.co/api/v1/detections/vulnerabilities/1/",
  "actions": "https://portal.patchman.co/api/v1/detections/vulnerabilities/1/actions/",
  "allowed_actions": [
    "patch",
    "block"
  ],
  "path": "/home/username/domains/domain.com/public_html/software/file.php",
  "state": "waiting",
  "detected_at": "2015-01-01T12:00:00Z",
  "resolution_scheduled_at": "2015-01-15T12:00:00Z",
  "resolution_requested_at": null,
  "resolution_reverted_at": null,
  "resolved_at": null,
  "retracted_at": null,
  "end_user": "https://portal.patchman.co/api/v1/endusers/1/",
  "definitions": [
    {
      "id": 1,
      "name": "First vulnerability",
      "description": "Background information for the first vulnerability",
      "type": "CSRF",
      "application": "Application"
    },
    {
      "id": 2,
      "name": "Second vulnerability",
      "description": "Background information for the second vulnerability",
      "type": "XSS",
      "application": "Application"
    }
  ]
}

Vulnerability actions

Each vulnerability detection has actions associated with it to denote the various changes that can be made to a file that was detected as vulnerable. You cannot modify existing actions, but you are allowed to create new actions.

Vulnerability action objects

type:
string The action type. Valid values (when reading) are detection, reminder, retraction, retraction_changed, retraction_deleted, retraction_definition_retracted, retraction_definition_superseded, patch, undo_patch, block and unblock. When creating a new action, valid values are patch, undo_patch, block and unblock (depending on the detection state and your plan).
scheduled_at:
read-only datetime optional The time for which execution of this action is scheduled, if applicable.
issued_at:
read-only datetime optional The time at which the command belonging to this action was sent to the server, if applicable.
failed_at:
read-only datetime optional The time at which the server reported it failed performing the requested action, if applicable.
completed_at:
read-only datetime optional The time at which the server reported it performed the requested action, if applicable.
notified_at:
read-only datetime optional The time at which an e-mail was sent to the end-user regarding this action, if applicable.
{
  "type": "detection",
  "scheduled_at": null,
  "issued_at": null,
  "failed_at": null,
  "completed_at": "2015-01-01T12:00:00Z",
  "notified_at": null
}

File Cleans

If your plan allows it, malware rule detection files will be automatically cleaned by Patchman. Consecutive cleans within the grace period (of the last clean) are grouped together, unless the time between the first and a new clean is more than the grace period limit, which is a setting on your plan.

All fields on file cleans are read-only.

File clean objects

id:
read-only integer The unique identifier for this object.
username:
read-only string The username of the end-user.
domain:
read-only string The domain from the end-user the file clean is done for.
cleans:
read-only string A list of consecutive file cleans that are grouped together and are belonging to the current file clean.
id:
read-only integer The ID of the file clean operation.
performed_at:
read-only datetime Date when the file clean operation was performed.
full_detection_path:
read-only string The file path of the cleaned file.
billed_at:
read-only datetime The time this file clean has been billed, which is the time the invoice has been created. Returns null if the file clean has not been billed yet.
curl https://portal.patchman.co/api/v1/filecleans/
import requests
requests.get("https://portal.patchman.co/api/v1/filecleans/")
{
  "id": 1,
  "username": "username",
  "domain": "domain.com",
  "cleans": [
    {
      "id": 1,
      "cleaned_at": "2015-12-01T10:00:00Z",
      "full_detection_path": "/home/username/domains/domain.com/public_html/index.php"
    },
    {
      "id": 2,
      "cleaned_at": "2015-12-02T10:00:00Z",
      "full_detection_path": "/home/username/domains/domain.com/public_html/index.php"
    },
  ],
  "billed_at": "2016-01-01T00:00:00Z",
}

End-user Token Retrieval

Part of this API, but not publicly exposed (as this uses a different authentication scheme) is retrieving a token for end-user authentication. This token is used by the end-users of a server to access the Patchman Portal interface detailing their specific user. This API is intended for use by control panel plugins and only available if the plan of the organization enables end-user logins. Additionally, this API will return HTTP 403 errors if the end-user has no policy that allows end-user logins.

This API is only available using the license certificate and key issued to server and only from the same IP that has been registered with Patchman. Authentication occurs through HTTPS client certificates. For OAuth2 authentication see token_url on End-users.

After issuing a successful request, the API returns a URL you should redirect your user to. This URL will take care of placing an authentication cookie on the end-user's computer. Following this, the user will be redirected to the page provided in the next argument, or (if this is not provided) to the default user view. Note that the redirect URL is only valid for one minute.

Token Retrieval objects

username:
string The username of the user a token should be requested for.
next:
optional string The url you wish to redirect the user to.
redirect_to:
read-only The url you should redirect the user to.
curl https://client-portal.patchman.co/api/v1/token/ \
  --cert license/patchman.crt \
  --key license/patchman.key \
  -d username=enduser1234
If curl is compiled against NSS, a bug requires you to add:
  --cacert license/patchman.crt \
  --capath /etc/ssl/certs/
import requests
r = requests.post("https://client-portal.patchman.co/api/v1/token/",
          data={"username": "enduser1234"},
          cert=("license/patchman.crt", "license/patchman.key"))
{
  "username": "enduser1234",
  "redirect_to": "https://portal.patchman.co/t/login/token12345/"
}

File Reporting

Patchman has many definition signatures to detect malware scripts, but it is inevitable that some malware may slip through. When you encounter such scripts, we would like to add it to our repository. This public API method allows you to submit malware samples to our reviewers, which may then result in adding it to our database.

Please try to be as descriptive as possible when submitting a file. Use the type field to describe in one or two words what you think the script is (e.g. phishing, spam, shell, etc) and the optional description field to add more context (e.g. observed behaviour, how you encountered it, etc).

File Report objects

report_type:
string The report type, typically malware
file:
file upload The file you want to report.
type:
optional string The type of the reported malware, e.g. 'spam' or 'phishing'.
description:
optional string A free-text field you can use to explain what happened and why you report this file.
curl https://portal.patchman.co/api/v1/report/ \
  -F report_type=malware \
  -F file=@evil.php \
  -F type=spam \
  -F "description=Found this while..."
r = requests.post("https://portal.patchman.co/api/v1/report/",
                  data={"report_type": "malware",
                        "type": "spam",
                        "description": "Found this while..."},
                  files={"file": ("evil.php", open("evil.php", "r"))})

Users

You can manage user accounts for the Portal through the API, for example if you wish to integrate this with the central staff user account management of your organization.

Note: upon creation of a user account through the API, a confirmation e-mail with the user's randomly generated password will be sent to the e-mail address you provide. There is no way to specify the password yourself.

User objects

name:
string The user's name.
email:
string The e-mail address of the user.
role:
string The role this user has (with associated permissions): owner, manager or staff.
{
  "url": "https://portal.patchman.co/api/v1/users/1/",
  "name": "John Doe",
  "email": "john@doe.com",
  "role": "manager"
}

Suborganizations

If your plan allows it, you can resell Patchman to your larger customers. Within Patchman, these are known as suborganizations. You can determine exactly which functionality of the product you want them to be able to tune themselves, while also keeping control through your own account. All billing will still pass through your own account.

Suborganization objects

users:
read-only string URI to retrieve a list of all users belonging to this suborganization.
name:
string The name of the organization.
email:
string The main contact e-mail address for the organization.
max_servers:
optional integer The maximum number of combined (physical and virtual) servers this suborganization can add (unlimited if left empty).
max_physical_servers:
optional integer The maximum number of physical servers this suborganization can add (unlimited if left empty).
max_virtual_servers:
optional integer The maximum number of virtual servers this suborganization can add (unlimited if left empty).
max_users:
optional integer The maximum number of Portal users this suborganization can add (unlimited if left empty).
can_add_servers:
boolean Indicates whether users for this organization can add servers to their organization.
can_change_servers:
boolean Indicates whether users for this organization can change server properties.
can_change_policies:
boolean Indicates whether users for this organization can change policies.
can_access_event_log:
boolean Indicates whether users for this organization can access the detection event log.
can_change_email_templates:
boolean Indicates whether users for this organization can change the contents of e-mail templates.
can_change_default_email_template:
boolean Indicates whether users for this organization can change the base e-mail template.
can_end_user_login:
boolean Indicates whether users for this organization can grant end users the option of logging in to the Portal.
can_access_api:
boolean Indicates whether users for this organization can access the Portal API.
{
  "url": "https://portal.patchman.co/api/v1/suborganizations/1/",
  "users": "https://portal.patchman.co/api/v1/suborganizations/1/users/",
  "name": "Organization X",
  "email": "info@organizationx.com",
  "max_servers": 10,
  "max_physical_servers": 10,
  "max_virtual_servers": 10,
  "max_users": null,
  "can_add_servers": true,
  "can_change_servers": true,
  "can_change_policies": false,
  "can_access_event_log": true,
  "can_change_email_templates": false,
  "can_change_default_email_template": false,
  "can_end_user_login": true,
  "can_access_api": false
}

Suborganization users

Like your own organization, suborganizations require one or more user accounts that can access the Portal, manage settings and view detections. The management of suborganization users is exactly the same as user management for your own organization.

Note: upon creation of a user account through the API, a confirmation e-mail with the user's randomly generated password will be sent to the e-mail address you provide. There is no way to specify the password yourself.

User objects

name:
string The user's name.
email:
string The e-mail address of the user.
role:
string The role this user has (with associated permissions): owner, manager or staff.
{
  "url": "https://portal.patchman.co/api/v1/suborganizations/1/users/1/",
  "name": "John Doe",
  "email": "john@doe.com",
  "role": "manager"
}