> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vartiq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Webhooks

> Create and manage webhooks for your apps

## Create Webhook

Create a new webhook for an app.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const webhook = await vartiq.webhook.create({
    name: "Webhook name",
    url: "https://your-webhook-url.com",
    appId: "APP_ID",
    customHeaders: [{ key: "x-app", value: "x-value" }], // optional
    authMethod: "basic", // optional: "basic", "hmac", or "apiKey"
    userName: "username", // required if authMethod is "basic"
    password: "password", // required if authMethod is "basic"
    apiKey: "api-key", // required if authMethod is "apiKey"
    apiKeyHeader: "x-api-key", // required if authMethod is "apiKey"
    hmacHeader: "x-signature", // required if authMethod is "hmac"
    hmacSecret: "your-secret" // required if authMethod is "hmac"
  });
  ```

  {/* ```php PHP
    $webhook = $vartiq->webhook->create([
    "name" => "Webhook name",
    "url" => "https://your-webhook-url.com",
    "appId" => "APP_ID",
    "customHeaders" => [["key" => "x-app", "value" => "x-value"]], // optional
    "authMethod" => "basic", // optional: "basic", "hmac", or "apiKey"
    "userName" => "username", // required if authMethod is "basic"
    "password" => "password", // required if authMethod is "basic"
    "apiKey" => "api-key", // required if authMethod is "apiKey"
    "apiKeyHeader" => "x-api-key", // required if authMethod is "apiKey"
    "hmacHeader" => "x-signature", // required if authMethod is "hmac"
    "hmacSecret" => "your-secret" // required if authMethod is "hmac"
    ]);
    ``` */}
</CodeGroup>

## Create Webhook without an app

Create a new webhook for a project.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const webhook = await vartiq.webhook.create({
    projectId: "PROJECT_ID",
    environmentId: "ENVIRONMENT_ID",
    url: "https://your-webhook-url.com",
    customHeaders: [{ key: "x-key", value: "x-value" }], // optional
    authMethod: "basic", // optional: "basic", "hmac", or "apiKey"
    userName: "username", // required if authMethod is "basic"
    password: "password", // required if authMethod is "basic"
    apiKey: "api-key", // required if authMethod is "apiKey"
    apiKeyHeader: "x-api-key", // required if authMethod is "apiKey"
    hmacHeader: "x-signature", // required if authMethod is "hmac"
    hmacSecret: "your-secret" // required if authMethod is "hmac"
  });
  ```
</CodeGroup>

## Get Webhooks

Get all webhooks for an app.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const webhooks = await vartiq.webhook.list("APP_ID");
  ```

  {/* ```php PHP
    $webhooks = $vartiq->webhook->list([
    "appId" => "APP_ID"
    ]);
    ``` */}
</CodeGroup>

## Get Webhook

Get a specific webhook by ID.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const webhook = await vartiq.webhook.get("WEBHOOK_ID");
  ```

  {/* ```php PHP
    $webhook = $vartiq->webhook->get("WEBHOOK_ID");
    ``` */}
</CodeGroup>

## Update Webhook

Update an existing webhook.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const webhook = await vartiq.webhook.update("WEBHOOK_ID", {
    name: "New name", // optional
    url: "https://new-url.com" // optional
  });
  ```

  {/* ```php PHP
    $webhook = $vartiq->webhook->update("WEBHOOK_ID", [
    "name" => "New name", // optional
    "url" => "https://new-url.com" // optional
    ]);
    ``` */}
</CodeGroup>

## Delete Webhook

Delete a webhook.

<CodeGroup>
  ```javascript JavaScript theme={null}
  await vartiq.webhook.delete("WEBHOOK_ID");
  ```

  {/* ```php PHP
    $vartiq->webhook->delete("WEBHOOK_ID");
    ``` */}
</CodeGroup>
