Set up the Search and Destroy API with service accounts

The Search and Destroy API lets your SOAR find a reported threat, search your users' mailboxes for its copies, and delete them without anyone opening Hoxhunt. A SOAR playbook (for example in Cortex XSOAR), a SIEM rule, or a script can call it. To learn how Search and Destroy itself works, see What is Search and Destroy?

What your SOAR can do with the API

A SOAR playbook, SIEM rule, or script that calls the API can:

  • Read incidents, the searches started for an incident, and the emails each search found.
  • Search your users' mailboxes for the emails of one incident.
  • Delete the emails a search found, all of them or a chosen set.
  • Recover emails it deleted, if the delete was a mistake.

A search finds emails received in the last 30 days and skips Sent Items, the same as a search started in Hoxhunt.

If automatic deletion is on in your Search and Destroy settings, a search started through the API also deletes the emails those settings allow, the same as a search started in Hoxhunt. Otherwise, your SOAR deletes them with a separate call.

Deleted emails go to the Recoverable Items (Deletions) folder of each mailbox, so they can be recovered.

How access works

A service account is the user your SOAR signs in as. It belongs to your organization, holds its own roles, and signs in with a key (a client ID and a client secret).

The incident timeline in Respond names the service account for each action taken through the API.

Before you start

Check these three things first:

  1. Search and Destroy is set up. It's turned on in your Search and Destroy settings, with your Microsoft tenant and domains added. Without it, your SOAR can still list and read incidents, but it can't start a search, delete, or recover emails. See How to enable Search and Destroy.
  2. You have the Admin role. Service accounts are an admin setting.
  3. You also have the Security remediator role. To give a service account the Search and Destroy API role, or to create a key for an account that has it, you need Security remediator too. You can only give out access that you have yourself. See User roles in Hoxhunt.

Create a service account

  1. In the Hoxhunt admin app, go to Settings > Technical implementation > Service accounts. You can also get there from the Overview tab of your Search and Destroy settings, through Manage API access with service accounts.

  2. Select Create service account.
  3. In Name, enter the name of the SOAR or script that will use the account, for example "Cortex XSOAR".
  4. In Description, add a note if you want one (optional).
  5. Under Roles, select Search and Destroy API.

  6. Select Create service account to save the account.

Create a key

  1. On the service account, select Create key.
  2. In Description, write where the key will be used, so you know which key to revoke later (optional).
  3. In Expires in, choose 30 days (the default), 90 days, 180 days, or 1 year (365 days). To replace a key before it expires, see Rotate a key with no downtime below.

  4. Select Create key. The dialog changes to Key created and shows two values, each with a copy button:

    • Client ID: the ID of the service account.
    • Client secret: the key itself.

  5. Copy the client secret now. Hoxhunt keeps only a hash of it and can never show it again. The dialog stays open until you select Close.

Store the client ID and client secret in your SOAR's credential store.

NOTE
Never send a client secret to Hoxhunt support or paste it into a ticket or chat. If you did, revoke that key and create a new one.

Connect your SOAR

Your SOAR uses the client ID and client secret to get an access token. The Search and Destroy API reference needs no login. It has a getting started guide, every operation, and the errors each operation can return.

Use api.hoxhunt.com as the host.

Rotate a key with no downtime

A key doesn't renew, so create the next one before the current one expires:

  1. Create a new key while the old one still works. An account can have 2 active keys.
  2. Move your SOAR to the new client secret.
  3. Revoke the old key.

If you lose a client secret, you can't recover it. Follow the same three steps.

Revoke a key, disable an account, or edit roles

  • Revoke a key: in the key list, select Revoke, then Revoke key. Anything using that key to call Hoxhunt stops working.
  • Disable an account: select Disable, then Disable account. None of its keys work after that, and you can't enable the account again. There's no delete either. To start over, create a new service account.
  • Edit roles: select Edit roles on the account. You can't edit a disabled account.

Revoking a key or disabling an account needs only the Admin role.

When a change takes effect

Change Takes effect
Revoke a key At once. The key and the tokens made from it stop on the next call.
A key expires At its expiry time, on the next call.
Disable an account New tokens stop at once. Tokens already given out stop within 60 seconds.
Change the roles Within 60 seconds.

Key statuses

The key list shows each key as Active, Expired, or Revoked. An active key of a disabled account shows Account disabled. For each key, the list also shows:

  • Who created it and when.
  • When it expires.
  • When it was last used (Never used if it hasn't been).

Troubleshooting

If your SOAR can't connect, check these first. For any other error, see the API reference.

  • Your SOAR can't get an access token. Check that the key isn't revoked or expired, that the account isn't disabled, and that the whole client secret was copied. A lost secret needs a new key.
  • Your SOAR is refused access. The service account doesn't have the Search and Destroy API role. Add it with Edit roles. The admin who adds it needs the Security remediator role.
  • Your SOAR can list incidents but can't search, delete, or recover. Search and Destroy is turned off, or no Microsoft tenant and domains are set up, in your Search and Destroy settings.

Messages in the admin app

  • "You can only give a service account the roles that you have yourself." You have the Admin role but not Security remediator, so you can't create an account with the Search and Destroy API role or add the role. Ask for the Security remediator role.
  • "You can only make keys for a service account whose roles you have yourself." Same cause, when you create a key. Ask for the Security remediator role.
  • "A service account with this name already exists. Choose another name." Names are unique in your organization.
  • "This account has 2 active keys, the most it can have. Revoke one to create a new key." Create key is turned off while the account has 2 active keys.
  • There's no Service accounts page. You don't have the Admin role.

Limits

What Limit
Key lifetime 30, 90, or 180 days, or 1 year (default 30 days)
Active keys per account 2

Security questions

Who can create API credentials?

Only a user with both the Admin and Security remediator roles can give a service account the Search and Destroy API role or create a key for it. Nobody can manage service accounts while impersonating another user.

How does Hoxhunt store the client secret?

Each client secret contains a random 256-bit value, and Hoxhunt stores only a SHA-256 hash of it, never the secret itself. Hoxhunt can never show the secret again after the Key created dialog closes.

How long do credentials last?

Every key expires, after 30 days by default and after 1 year at most. An access token lasts 5 minutes.

How fast does revoking access work?

A revoked key stops on its next call. When you disable an account, it gets no new tokens, and tokens already given out stop within 60 seconds.

What can a service account reach?

Only its own organization. Its roles decide what it can call; there are no separate scopes.

What data can the API read?

Incidents, the searches started for them, and the emails each search found, including the mailbox, sender, and subject. The API doesn't return email bodies or attachments. The API reference lists every field.

Which mail systems does it support?

Microsoft 365. The search runs on the Microsoft tenants and domains set up in your Search and Destroy settings.

Questions?

Contact your Customer Success Manager or support@hoxhunt.com.

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request