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

# Tenant API Code Examples in cURL, JS, PHP, Python

> Copy-ready Sinjapp Tenant API examples for sending messages, listing logs, and reading usage in cURL, JavaScript, PHP, and Python.

Use these examples as a starting point for your integration. Replace `{tenant}` with your tenant subdomain and keep API keys on the server side.

## Send A Text Message

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://{tenant}.sinjapp.org/api/v1/messages" \
    -H "X-Api-Key: {tenant_api_key}" \
    -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d '{
      "sender_phone": "{sender_phone}",
      "to_phone": "{recipient_phone}",
      "type": "text",
      "content": "Hello from Sinjapp Business"
    }'
  ```

  ```js JavaScript theme={null}
  const response = await fetch('https://{tenant}.sinjapp.org/api/v1/messages', {
    method: 'POST',
    headers: {
      'X-Api-Key': tenantApiKey,
      'Accept': 'application/json',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      sender_phone: senderPhone,
      to_phone: recipientPhone,
      type: 'text',
      content: 'Hello from Sinjapp Business',
    }),
  })

  const message = await response.json()
  ```

  ```php PHP theme={null}
  <?php

  $response = file_get_contents('https://{tenant}.sinjapp.org/api/v1/messages', false, stream_context_create([
      'http' => [
          'method' => 'POST',
          'header' => [
              'X-Api-Key: ' . $tenantApiKey,
              'Accept: application/json',
              'Content-Type: application/json',
          ],
          'content' => json_encode([
              'sender_phone' => $senderPhone,
              'to_phone' => $recipientPhone,
              'type' => 'text',
              'content' => 'Hello from Sinjapp Business',
          ]),
          'timeout' => 30,
      ],
  ]));

  $message = json_decode($response, true);
  ```

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

  response = requests.post(
      "https://{tenant}.sinjapp.org/api/v1/messages",
      headers={
          "X-Api-Key": tenant_api_key,
          "Accept": "application/json",
          "Content-Type": "application/json",
      },
      json={
          "sender_phone": sender_phone,
          "to_phone": recipient_phone,
          "type": "text",
          "content": "Hello from Sinjapp Business",
      },
      timeout=30,
  )

  message = response.json()
  ```
</CodeGroup>

## Check Contact Reachability

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://{tenant}.sinjapp.org/api/v1/contacts/lookup?phone={recipient_phone}&sender_phone={sender_phone}" \
    -H "X-Api-Key: {tenant_api_key}" \
    -H "Accept: application/json"
  ```

  ```js JavaScript theme={null}
  const params = new URLSearchParams({
    phone: recipientPhone,
    sender_phone: senderPhone,
  })

  const response = await fetch(`https://{tenant}.sinjapp.org/api/v1/contacts/lookup?${params}`, {
    headers: {
      'X-Api-Key': tenantApiKey,
      'Accept': 'application/json',
    },
  })

  const lookup = await response.json()
  ```

  ```php PHP theme={null}
  <?php

  $query = http_build_query([
      'phone' => $recipientPhone,
      'sender_phone' => $senderPhone,
  ]);

  $response = file_get_contents('https://{tenant}.sinjapp.org/api/v1/contacts/lookup?' . $query, false, stream_context_create([
      'http' => [
          'method' => 'GET',
          'header' => [
              'X-Api-Key: ' . $tenantApiKey,
              'Accept: application/json',
          ],
          'timeout' => 30,
      ],
  ]));

  $lookup = json_decode($response, true);
  ```

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

  response = requests.get(
      "https://{tenant}.sinjapp.org/api/v1/contacts/lookup",
      headers={
          "X-Api-Key": tenant_api_key,
          "Accept": "application/json",
      },
      params={
          "phone": recipient_phone,
          "sender_phone": sender_phone,
      },
      timeout=30,
  )

  lookup = response.json()
  ```
</CodeGroup>
