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

# Subscribe to Project Webhooks

> Set up real-time webhook notifications for new project creation events in your Zapier integrations.

## Overview

Subscribe to webhook events to receive instant notifications when projects are created in your workspace. This endpoint enables Zapier's "New Project" trigger integration, automatically forwarding project data to your connected workflows.

<Note>
  This endpoint is primarily designed for Zapier integrations but can be used with any webhook service that follows the same pattern.
</Note>

## Authentication

All requests require a valid API key in the Authorization header:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

## Subscribe to Events

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://app.timetracker.in/api/integrations/zapier/webhooks/subscribe' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -d '{
      "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
      "events": ["PROJECT_CREATED"],
      "description": "Zapier webhook for new projects"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.timetracker.in/api/integrations/zapier/webhooks/subscribe', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: JSON.stringify({
      url: 'https://hooks.zapier.com/hooks/catch/123456/abcdef/',
      events: ['PROJECT_CREATED'],
      description: 'Zapier webhook for new projects'
    })
  });
  ```

  ```python Python theme={null}
  import requests

  url = "https://app.timetracker.in/api/integrations/zapier/webhooks/subscribe"
  headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer YOUR_API_KEY"
  }
  data = {
      "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
      "events": ["PROJECT_CREATED"],
      "description": "Zapier webhook for new projects"
  }

  response = requests.post(url, headers=headers, json=data)
  ```
</CodeGroup>

### Request Body

<ParamField body="url" type="string" required>
  The destination URL for webhook notifications. Must be a valid HTTPS URL format.

  **Example:** `https://hooks.zapier.com/hooks/catch/123456/abcdef/`
</ParamField>

<ParamField body="events" type="string[]" required>
  Array of event types to monitor. Currently supports:

  * `PROJECT_CREATED` - Triggered when a new project is added

  **Example:** `["PROJECT_CREATED"]`
</ParamField>

<ParamField body="description" type="string" optional>
  Optional description to identify this webhook in your dashboard.

  **Example:** `"Zapier integration for project notifications"`
</ParamField>

## Response

### Success Response

```json theme={null}
{
  "success": true,
  "webhook": {
    "id": "wh_1234567890abcdef",
    "url": "https://hooks.zapier.com/hooks/catch/123456/abcdef/",
    "events": ["PROJECT_CREATED"],
    "status": "ACTIVE"
  }
}
```

<ResponseField name="success" type="boolean">
  Confirms successful webhook creation.
</ResponseField>

<ResponseField name="webhook" type="object">
  The created webhook subscription details.

  <Expandable title="Webhook Object Properties">
    <ResponseField name="id" type="string">
      Unique webhook identifier for future reference.
    </ResponseField>

    <ResponseField name="url" type="string">
      The registered webhook endpoint URL.
    </ResponseField>

    <ResponseField name="events" type="string[]">
      Confirmed list of subscribed event types.
    </ResponseField>

    <ResponseField name="status" type="string">
      Webhook status - `ACTIVE` for new subscriptions.
    </ResponseField>
  </Expandable>
</ResponseField>

### Error Responses

<AccordionGroup>
  <Accordion title="400 Bad Request - Invalid URL">
    ```json theme={null}
    {
      "error": "Invalid URL format"
    }
    ```

    The provided URL doesn't meet the required format standards.
  </Accordion>

  <Accordion title="400 Bad Request - Missing Fields">
    ```json theme={null}
    {
      "error": "URL and events array are required"
    }
    ```

    Required parameters `url` or `events` are missing from the request.
  </Accordion>

  <Accordion title="401 Unauthorized">
    ```json theme={null}
    {
      "error": "Unauthorized"
    }
    ```

    Invalid or missing API key in the Authorization header.
  </Accordion>

  <Accordion title="500 Internal Server Error">
    ```json theme={null}
    {
      "error": "Internal server error"
    }
    ```

    An unexpected server error occurred. Try again or contact support.
  </Accordion>
</AccordionGroup>

## Webhook Payload Structure

When a project is created, your webhook endpoint receives a POST request with this payload:

```json theme={null}
{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "name": "New Mobile App Project",
  "description": "Development of a new mobile application",
  "status": "active",
  "workspace": {
    "id": "345e6789-e89b-12d3-a456-426614174004",
    "name": "Development Team"
  },
  "client": {
    "id": "456e7890-e89b-12d3-a456-426614174001",
    "name": "Tech Startup Inc.",
    "email": "contact@techstartup.com",
    "phone": "+1-555-0123",
    "status": "active",
    "type": "company"
  },
  "defaultBillable": true,
  "defaultBillableRate": 75.0,
  "estimatedHours": 200.0,
  "estimatedBudget": 15000.0,
  "isPrivate": false,
  "createdAt": "2024-01-15T10:00:00.000Z",
  "updatedAt": "2024-01-15T10:00:00.000Z"
}
```

### Payload Fields

<ResponseField name="id" type="string">
  Unique project identifier
</ResponseField>

<ResponseField name="name" type="string">
  Project name
</ResponseField>

<ResponseField name="description" type="string">
  Project description
</ResponseField>

<ResponseField name="status" type="string">
  Project status (`active`, `inactive`, `completed`, etc.)
</ResponseField>

<ResponseField name="workspace" type="object">
  Associated workspace information

  <Expandable title="Workspace Properties">
    <ResponseField name="id" type="string">
      Workspace unique identifier
    </ResponseField>

    <ResponseField name="name" type="string">
      Workspace display name
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="client" type="object">
  Associated client information

  <Expandable title="Client Properties">
    <ResponseField name="id" type="string">
      Client unique identifier
    </ResponseField>

    <ResponseField name="name" type="string">
      Client name
    </ResponseField>

    <ResponseField name="email" type="string">
      Client email address
    </ResponseField>

    <ResponseField name="phone" type="string">
      Client phone number
    </ResponseField>

    <ResponseField name="status" type="string">
      Client status
    </ResponseField>

    <ResponseField name="type" type="string">
      Client type (company, individual, etc.)
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="defaultBillable" type="boolean">
  Whether time entries are billable by default
</ResponseField>

<ResponseField name="defaultBillableRate" type="number">
  Default hourly rate for billable time
</ResponseField>

<ResponseField name="estimatedHours" type="number">
  Estimated total hours for the project
</ResponseField>

<ResponseField name="estimatedBudget" type="number">
  Estimated total budget for the project
</ResponseField>

<ResponseField name="isPrivate" type="boolean">
  Whether the project is private
</ResponseField>

<ResponseField name="createdAt" type="string">
  ISO 8601 timestamp of project creation
</ResponseField>

<ResponseField name="updatedAt" type="string">
  ISO 8601 timestamp of last update
</ResponseField>

## Zapier Integration Guide

### Setting Up the Trigger

1. **Automatic Setup**: Zapier automatically calls this endpoint when you configure a "New Project" trigger
2. **Event Subscription**: The integration subscribes to `PROJECT_CREATED` events
3. **Data Flow**: New project data is instantly sent to your Zap workflow

<Tip>
  Zapier automatically provides the webhook URL via `bundle.targetUrl` when setting up the trigger. You don't need to manually generate URLs.
</Tip>

## Important Notes

<Warning>
  **Workspace Scope**: Webhook subscriptions are tied to your specific API key and workspace. Ensure you're using the correct credentials for your intended workspace.
</Warning>

<Info>
  **Data Format**: The webhook payload structure matches the standard project data format used across all project API endpoints, ensuring consistency in your integrations.
</Info>

<Check>
  **Best Practices**:

  * Validate webhook signatures if implementing custom security
  * Implement proper error handling for webhook delivery failures
  * Use HTTPS endpoints only for security
  * Test your webhook endpoint before subscribing
</Check>
