> ## 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.

# Create Client

> Create a new client in your workspace through the Zapier integration API.

## Overview

Create a new client in your workspace using the Zapier integration API. This endpoint allows you to add clients with comprehensive information including contact details, billing preferences, and workspace associations.

<Note>
  This endpoint is designed for Zapier integrations but can be used with any application that needs to create clients programmatically.
</Note>

## Authentication

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

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

## Create Client

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://app.timetracker.in/api/integrations/zapier/triggers/clients' \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer YOUR_API_KEY' \
    -d '{
      "name": "Acme Corporation",
      "type": "company",
      "status": "active",
      "email": "info@acmecorp.com",
      "phone": "+1-800-555-0199",
      "address": "456 Innovation Drive, Silicon Valley, CA 94043",
      "note": "Enterprise client with multiple projects",
      "currency": "USD",
      "workspace_id": "w1b2c3d4-e5f6-7890-abcd-ef0987654321"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.timetracker.in/api/integrations/zapier/triggers/clients', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer YOUR_API_KEY'
    },
    body: JSON.stringify({
      name: 'Acme Corporation',
      type: 'company',
      status: 'active',
      email: 'info@acmecorp.com',
      phone: '+1-800-555-0199',
      address: '456 Innovation Drive, Silicon Valley, CA 94043',
      note: 'Enterprise client with multiple projects',
      currency: 'USD',
      workspace_id: 'w1b2c3d4-e5f6-7890-abcd-ef0987654321'
    })
  });

  const client = await response.json();
  ```

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

  url = "https://app.timetracker.in/api/integrations/zapier/triggers/clients"
  headers = {
      "Content-Type": "application/json",
      "Authorization": "Bearer YOUR_API_KEY"
  }
  data = {
      "name": "Acme Corporation",
      "type": "company",
      "status": "active",
      "email": "info@acmecorp.com",
      "phone": "+1-800-555-0199",
      "address": "456 Innovation Drive, Silicon Valley, CA 94043",
      "note": "Enterprise client with multiple projects",
      "currency": "USD",
      "workspace_id": "w1b2c3d4-e5f6-7890-abcd-ef0987654321"
  }

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

### Request Body

<ParamField body="name" type="string" required>
  The name of the client or company. Must be between 1-255 characters.

  **Example:** `"Acme Corporation"`
</ParamField>

<ParamField body="workspace_id" type="string" required>
  The UUID of the workspace where the client will be created.

  **Example:** `"w1b2c3d4-e5f6-7890-abcd-ef0987654321"`
</ParamField>

<ParamField body="type" type="string" default="individual">
  The type of client. Valid values:

  * `individual` - Individual person
  * `company` - Business or organization

  **Example:** `"company"`
</ParamField>

<ParamField body="status" type="string" default="active">
  The current status of the client. Valid values:

  * `active` - Client is currently active
  * `inactive` - Client is temporarily inactive

  **Example:** `"active"`
</ParamField>

<ParamField body="email" type="string">
  The primary contact email address. Must be a valid email format.

  **Example:** `"info@acmecorp.com"`
</ParamField>

<ParamField body="phone" type="string">
  Contact phone number. Can include country code and formatting.

  **Example:** `"+1-800-555-0199"`
</ParamField>

<ParamField body="address" type="string">
  Complete business or mailing address.

  **Example:** `"456 Innovation Drive, Silicon Valley, CA 94043"`
</ParamField>

<ParamField body="note" type="string">
  Additional notes or comments about the client.

  **Example:** `"Enterprise client with multiple projects"`
</ParamField>

<ParamField body="currency" type="string" default="USD">
  The default currency for client billing. Should be a valid ISO currency code.

  **Example:** `"USD"`
</ParamField>

## Response

### Success Response

Returns the created client object with all associated data:

```json theme={null}
{
  "id": "c1a2b3c4-d5e6-7890-abcd-ef1234567890",
  "name": "Acme Corporation",
  "type": "company",
  "status": "active",
  "email": "info@acmecorp.com",
  "phone": "+1-800-555-0199",
  "address": "456 Innovation Drive, Silicon Valley, CA 94043",
  "note": "Enterprise client with multiple projects",
  "currency": "USD",
  "workspaces": [
    {
      "id": "w1b2c3d4-e5f6-7890-abcd-ef0987654321",
      "name": "Acme Main Workspace"
    }
  ],
  "projects": [],
  "project_count": 0,
  "workspace_count": 1,
  "created_at": "2024-01-15T10:30:00.000Z",
  "updated_at": "2024-01-15T10:30:00.000Z"
}
```

### Response Fields

<ResponseField name="id" type="string">
  Unique client identifier (UUID format)
</ResponseField>

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

<ResponseField name="type" type="string">
  Client type (`individual` or `company`)
</ResponseField>

<ResponseField name="status" type="string">
  Current client status (`active` or `inactive`)
</ResponseField>

<ResponseField name="email" type="string">
  Primary contact email address
</ResponseField>

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

<ResponseField name="address" type="string">
  Complete business address
</ResponseField>

<ResponseField name="note" type="string">
  Additional notes about the client
</ResponseField>

<ResponseField name="currency" type="string">
  Default currency for billing
</ResponseField>

<ResponseField name="workspaces" type="array">
  Array of associated workspaces

  <Expandable title="Workspace Object">
    <ResponseField name="id" type="string">
      Unique workspace identifier
    </ResponseField>

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

<ResponseField name="projects" type="array">
  Array of associated projects

  <Expandable title="Project Object">
    <ResponseField name="id" type="string">
      Unique project identifier
    </ResponseField>

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

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

    <ResponseField name="workspace_id" type="string">
      Associated workspace ID
    </ResponseField>

    <ResponseField name="workspace_name" type="string">
      Associated workspace name
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="project_count" type="integer">
  Total number of projects associated with this client
</ResponseField>

<ResponseField name="workspace_count" type="integer">
  Total number of workspaces associated with this client
</ResponseField>

<ResponseField name="created_at" type="string">
  ISO 8601 timestamp when client was created
</ResponseField>

<ResponseField name="updated_at" type="string">
  ISO 8601 timestamp when client was last modified
</ResponseField>

### Error Responses

<AccordionGroup>
  <Accordion title="400 Bad Request - Validation Error">
    ```json theme={null}
    {
      "error": "Invalid request body",
      "details": [
        {
          "field": "name",
          "message": "String must contain at least 1 character(s)"
        }
      ]
    }
    ```

    **Cause**: Required fields are missing or invalid\
    **Solution**: Check the request body and ensure all required fields are provided with valid values
  </Accordion>

  <Accordion title="400 Bad Request - Invalid Email">
    ```json theme={null}
    {
      "error": "Invalid request body",
      "details": [
        {
          "field": "email",
          "message": "Invalid email"
        }
      ]
    }
    ```

    **Cause**: Email format is invalid\
    **Solution**: Provide a valid email address format
  </Accordion>

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

    **Cause**: Invalid or missing API key\
    **Solution**: Verify your API key is correct and properly formatted
  </Accordion>

  <Accordion title="404 Not Found - Workspace">
    ```json theme={null}
    {
      "error": "Workspace not found"
    }
    ```

    **Cause**: The specified workspace\_id doesn't exist or you don't have access to it\
    **Solution**: Verify the workspace ID and ensure you have proper permissions
  </Accordion>

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

    **Cause**: Server-side error during client creation\
    **Solution**: Retry the request or contact support if the issue persists
  </Accordion>
</AccordionGroup>

## Zapier Integration

### Zapier Action Configuration

When using this endpoint in Zapier:

1. **Workspace Selection**: Use the dynamic dropdown to select the target workspace
2. **Required Fields**: Only `name` and `workspace_id` are required
3. **Optional Fields**: All other fields can be left empty for default values
4. **Data Mapping**: Map fields from previous steps in your Zap workflow

### Sample Zapier Usage

<Steps>
  <Step title="Trigger Setup">
    Set up a trigger (e.g., new form submission, new email) that provides client information
  </Step>

  <Step title="Action Configuration">
    Configure the "Create Client" action with:

    * **Workspace**: Select your target workspace
    * **Client Name**: Map from trigger data
    * **Email**: Map from trigger data (if available)
    * **Phone**: Map from trigger data (if available)
  </Step>

  <Step title="Optional Fields">
    Add any additional client information:

    * **Type**: Set to "company" or "individual"
    * **Address**: Full business address
    * **Notes**: Additional context about the client
  </Step>

  <Step title="Test & Activate">
    Test the Zap with sample data, then activate for live use
  </Step>
</Steps>

## Use Cases

<AccordionGroup>
  <Accordion title="Lead Management">
    **CRM Integration**: Automatically create clients when new leads are added to your CRM system, ensuring seamless data flow between platforms.
  </Accordion>

  <Accordion title="Form Submissions">
    **Website Forms**: Create clients automatically when potential customers submit contact forms on your website, reducing manual data entry.
  </Accordion>

  <Accordion title="Email Processing">
    **Email Automation**: Parse incoming emails and create client records based on email content or sender information.
  </Accordion>

  <Accordion title="Data Migration">
    **System Migration**: Bulk import clients from other systems during migration or data synchronization processes.
  </Accordion>
</AccordionGroup>

## Important Notes

<Warning>
  **Workspace Association**: Clients are automatically associated with the specified workspace. Ensure you're using the correct workspace ID for your intended organization.
</Warning>

<Info>
  **Duplicate Prevention**: The system allows multiple clients with the same name. If you need to prevent duplicates, implement validation logic in your integration.
</Info>

<Check>
  **Best Practices**:

  * Always validate email format before sending requests
  * Use descriptive notes to provide context about the client
  * Include phone numbers with country codes for international clients
  * Test with sample data before implementing in production
  * Handle error responses gracefully in your application
</Check>

## Rate Limits

* **Rate Limit**: 100 requests per minute per API key
* **Burst Limit**: 10 requests per second
* **Daily Limit**: 10,000 requests per day

<Note>
  Rate limits are applied per API key and workspace combination. Contact support if you need higher limits for your use case.
</Note>
