External API TARGPatrol
Integrating TARGPatrol with other systems can significantly expand your organization's functionality and improve efficiency. This guide will show you how to set up integration using the External API of TARGPatrol.

Obtaining an API Key

1. Go to the web application app.targpatrol.com and log in with your account.
Obtaining an API Key
2. Navigate to the "Management" -> "External API" section (this section will only be available to users with the Owner role).
3. Click the "Add Token" button.
Obtaining an API Key
4. Then click "Save," and the token will appear in the table.
5. Next, click the copy token icon.

API Documentation and Testing

  1. Open the API documentation at https://api.targpatrol.com

  2. Review the available endpoints and their capabilities. For example, you can find endpoints for creating tasks, managing users, and more.

  3. Use the testing capabilities directly in the documentation, or use third-party tools like Postman to ensure your API key works correctly.

API Documentation and Testing

Integration Setup

Example Integration with a CRM System
  1. Authorization: Use your API key to authenticate requests to TARGPatrol. Add it to your request headers:

    Authorization: Bearer YOUR_API_KEY

  2. Creating a Task from the CRM: When a new deal or request is created in your CRM system, you can automatically create a task in TARGPatrol. Example request to create a task:

    POST
    {
      "assigneeIds": [
        "4f9e4741-3069-4a03-8386-5f3ee45791aa"
      ],
      "locationId": "03864752-f177-47ff-b0a1-99d75b02d954",
      "name": "task 1",
      "description": null,
      "recurrence": {
        "rule": "FREQ=DAILY;UNTIL=20230309T210000Z",
        "exception": "20230307T210000Z,20230309T210000Z"
      },
      "startAt": "2023-03-06T18:00:00.000Z",
      "endAt": "2023-03-06T21:00:00.000Z",
      "priority": "NORMAL",
      "orderStepsRequired": true,
      "strictTimeRequired": false,
      "deadlined": false,
      "tags": [
        "task 1"
      ],
      "steps": [
        {
          "pointId": "9facfd8e-1fe3-4449-80be-1003bcf238a2",
          "name": "step 1",
          "order": 0,
          "actions": [
            {
              "name": "action 1",
              "type": "BOOLEAN",
              "order": 0,
              "required": false
            },
            {
              "name": "action 2",
              "type": "NUMBER",
              "order": 1,
              "required": true,
              "minValue": 11.1,
              "maxValue": 12.1
            }
          ]
        }
      ]
    }
    

  3. Getting Task Status: Periodically request the status of tasks related to requests in the CRM to update information in both systems.Example request to get task information:

    GET
    [
      {
        "id": "6a4900f9-2b4b-4d0c-a57d-d824278c18a7",
        "scheduledTaskId": "db13a59b-f447-4c3f-b375-48d692eba9e3",
        "scheduledTaskHistoryId": 1264,
        "executedTaskId": null,
        "name": "task 1",
        "description": null,
        "locationId": "03864752-f177-47ff-b0a1-99d75b02d954",
        "locationHistoryId": 1,
        "seenStates": [
          {
            "assigneeId": "4f9e4741-3069-4a03-8386-5f3ee45791aa",
            "assigneeHistoryId": 1,
            "seen": false
          }
        ],
        "performerId": null,
        "status": null,
        "state": "PLANNED",
        "published": true,
        "startAt": "2023-03-06T18:00:00.000Z",
        "endAt": "2023-03-06T21:00:00.000Z",
        "startedAt": null,
        "endedAt": null,
        "totalExecutedTimeInMillis": null,
        "lateStart": null,
        "lateEnd": null,
        "latenessInMillis": null,
        "expired": false,
        "seriesId": "56c01a98-f4c6-4b2b-89f3-2420432c6906",
        "recurrence": {
          "rule": "FREQ=DAILY;UNTIL=20230309T210000Z",
          "exception": "20230307T210000Z,20230309T210000Z"
        },
        "keptOrder": null,
        "skippedStepCount": null,
        "skippedActionCount": null,
        "numericErrorCount": null,
        "missingRequiredValuesCount": null,
        "executedStepCount": null,
        "orderStepsRequired": false,
        "strictTimeRequired": false,
        "deadlined": false,
        "priority": "NORMAL",
        "tags": [
          "task 1"
        ],
        "collision": null,
        "edited": null,
        "editedAt": "2024-08-20T08:16:26.742Z",
        "stepCount": 1,
        "warningCount": 0,
        "errorCount": 0,
        "notes": null,
        "favorite": false,
        "steps": [
          {
            "id": "c72ba560-203e-4fb6-8ab4-9a4907beffb7",
            "scheduledStepId": "b5091e3d-3e73-4406-b25d-a4cd9ae9cd28",
            "seriesId": "15854da1-fdc8-4320-8155-b2e5708d64a1",
            "scheduledStepHistoryId": 9963,
            "executedStepId": null,
            "name": "Step 1",
            "pointId": "9facfd8e-1fe3-4449-80be-1003bcf238a2",
            "pointHistoryId": 5,
            "order": 0,
            "actualOrder": null,
            "status": null,
            "state": null,
            "keptOrder": null,
            "actions": [
              {
                "id": "67f2771c-ab7d-42b8-a861-2464fd7dd9a8",
                "scheduledActionId": "093a3679-0ecd-4db5-b59c-dfc37eceff44",
                "seriesId": "d815ac98-d16c-4b2f-bb1a-c59de9305f28",
                "scheduledActionHistoryId": 5712,
                "executedActionId": null,
                "name": "action 1",
                "type": "BOOLEAN",
                "order": 0,
                "status": null,
                "state": null,
                "required": false,
                "validAction": null,
                "missedRequiredValue": null,
                "minValue": null,
                "maxValue": null,
                "booleanValue": null,
                "mediaValueIds": null,
                "numberValue": null,
                "textValue": null,
                "hasMedia": null
              },
              {
                "id": "eff1df72-4f32-41a3-b06f-8f8fbf4da259",
                "scheduledActionId": "306a321c-2fd8-4d03-aa72-5eb19566b074",
                "seriesId": "4992e0aa-9c20-4e09-bc4e-c4641e9ec196",
                "scheduledActionHistoryId": 5713,
                "executedActionId": null,
                "name": "action 2",
                "type": "NUMBER",
                "order": 1,
                "status": null,
                "state": null,
                "required": true,
                "validAction": null,
                "missedRequiredValue": null,
                "minValue": 11.1,
                "maxValue": 12.1,
                "booleanValue": null,
                "mediaValueIds": null,
                "numberValue": null,
                "textValue": null,
                "hasMedia": null
              }
            ]
          }
        ]
      }
    ]
                

Conclusion

Integrating TARGPatrol with other systems using the External API allows you to automate numerous processes and ensure more efficient task management. Follow this guide to set up the integration and leverage all the benefits it offers. Remember to regularly check the documentation and API updates for the most current information.