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

# Integration Examples

> Integrate with Zapier, Make, and other platforms

## Zapier Integration

### Setup

1. **Create a Zapier App**: Use the HTTP Request action
2. **Authentication**: Configure API key in Zapier's authentication settings
3. **Triggers**: Use webhooks or polling to detect new records
4. **Actions**: Create records using POST endpoints with AI prompts

### Example: Create Invoice Trigger

<CodeGroup>
  ```javascript Zapier Code theme={null}
  const response = await fetch('https://api.usetyms.com/v1/adam/invoices', {
    method: 'POST',
    headers: {
      'X-API-Key': bundle.authData.api_key,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      prompt: `Create an invoice for ${bundle.inputData.customer} for $${bundle.inputData.amount} for ${bundle.inputData.description}`
    })
  });

  return response.json();
  ```
</CodeGroup>

## Make (Integromat) Integration

### Setup

1. **HTTP Module**: Configure with base URL `https://api.usetyms.com/v1/adam`
2. **Authentication**: Add API key header (`X-API-Key`)
3. **Data Mapping**: Map your data to API request format
4. **Error Handling**: Handle API errors appropriately

### Example: HTTP Request Configuration

* **Method**: POST
* **URL**: `https://api.usetyms.com/v1/adam/invoices`
* **Headers**:
  * `X-API-Key`: Your API key
  * `Content-Type`: `application/json`
* **Body**:

```json theme={null}
{
  "prompt": "{{1.prompt}}"
}
```

## cURL Examples

### Create Invoice

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.usetyms.com/v1/adam/invoices" \
    -H "X-API-Key: your_secret_key" \
    -H "Content-Type: application/json" \
    -d '{
      "prompt": "Create an invoice for ABC Company for $1,000 for consulting services"
    }'
  ```
</CodeGroup>

### Update Invoice Payment

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://api.usetyms.com/v1/adam/invoices/invoice-uuid/payments" \
    -H "X-API-Key: your_secret_key" \
    -H "Content-Type: application/json" \
    -d '{
      "payments": [
        {
          "amount_paid": 500.00,
          "category": "Bank Transfer",
          "date": "2024-01-20"
        }
      ]
    }'
  ```
</CodeGroup>

### Get Contacts

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.usetyms.com/v1/adam/contacts?page=1&limit=20" \
    -H "X-API-Key: your_secret_key"
  ```
</CodeGroup>

## JavaScript/Node.js Example

<CodeGroup>
  ```javascript Node.js theme={null}
  const axios = require('axios');

  const apiClient = axios.create({
    baseURL: 'https://api.usetyms.com/v1/adam',
    headers: {
      'X-API-Key': 'your_secret_key',
      'Content-Type': 'application/json'
    }
  });

  // Create invoice
  async function createInvoice(prompt) {
    try {
      const response = await apiClient.post('/invoices', {
        prompt: prompt
      });
      return response.data;
    } catch (error) {
      console.error('Error creating invoice:', error.response?.data || error.message);
      throw error;
    }
  }

  // Get invoices
  async function getInvoices(page = 1, limit = 20) {
    try {
      const response = await apiClient.get('/invoices', {
        params: { page, limit }
      });
      return response.data;
    } catch (error) {
      console.error('Error fetching invoices:', error.response?.data || error.message);
      throw error;
    }
  }
  ```
</CodeGroup>

## Python Example

<CodeGroup>
  ```python Python theme={null}
  import requests

  class TymsAPI:
      def __init__(self, api_key):
          self.base_url = 'https://api.usetyms.com/v1/adam'
          self.headers = {
              'X-API-Key': api_key,
              'Content-Type': 'application/json'
          }
      
      def create_invoice(self, prompt):
          response = requests.post(
              f'{self.base_url}/invoices',
              headers=self.headers,
              json={'prompt': prompt}
          )
          response.raise_for_status()
          return response.json()
      
      def get_invoices(self, page=1, limit=20):
          response = requests.get(
              f'{self.base_url}/invoices',
              headers=self.headers,
              params={'page': page, 'limit': limit}
          )
          response.raise_for_status()
          return response.json()

  # Usage
  api = TymsAPI('your_secret_key')
  invoice = api.create_invoice('Create an invoice for ABC Company for $1,000')
  ```
</CodeGroup>

## Important Notes

* **Dates**: Use ISO 8601 (`YYYY-MM-DD`) in structured JSON where an endpoint requires a date field.
* **Amounts**: In structured JSON, use numeric amounts without currency symbols.
* **Timezone**: Defaults are documented in [Concepts](/concepts); validated business profile includes `timezone`.
* **AI creates**: Invoice, bill, expense, income, journal, contact, chart-of-accounts, and **`POST /bank-transactions/upload`** all use natural-language **`prompt`** (bank upload **requires** it — not a raw `transactions[]` bulk JSON importer). See [Create bank transactions (AI)](/api-reference/bank-transactions-upload).
* **Partners**: New businesses are provisioned with [Register business](/api-reference/register-business); day-to-day calls use each business’s `tyms_sk_...`.
* **UUID resolution**: Updates and deletes accept `uuid` or `source_uuid` where documented ([Overview](/api-reference/overview#uuid-resolution)).
