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

# Number Leasing

> Lease phone numbers for your messaging needs with Contiguity.

<Tabs>
  <Tab title="JavaScript" icon="js">
    ## Installing the SDK

    <Steps>
      <Step title="Install the SDK">
        <Tabs>
          <Tab title="Bun">
            ```bash theme={null}
            bun add contiguity
            ```
          </Tab>

          <Tab title="pnpm">
            ```bash theme={null}
            pnpm add contiguity
            ```
          </Tab>

          <Tab title="npm">
            ```bash theme={null}
            npm install contiguity
            ```
          </Tab>

          <Tab title="Yarn">
            ```bash theme={null}
            yarn add contiguity
            ```
          </Tab>
        </Tabs>
      </Step>

      <Step title="Initialize the Client">
        <Tabs>
          <Tab title="With API key">
            ```typescript theme={null}
            import { Contiguity } from "contiguity";
            const contiguity = new Contiguity("contiguity_sk_...your_key...");
            ```
          </Tab>

          <Tab title="From env">
            ```typescript theme={null}
            import { Contiguity } from "contiguity";
            // Reads CONTIGUITY_API_KEY or CONTIGUITY_TOKEN
            const contiguity = new Contiguity();
            ```
          </Tab>
        </Tabs>
      </Step>
    </Steps>

    ## Managing Number Leases

    Lease phone numbers to use as dedicated senders for your messages, improving deliverability and brand recognition.

    ## Check Available Numbers

    View available phone numbers that can be leased for your account.

    ```typescript theme={null}
    const res = await contiguity.lease.available();
    ```

    ## Get Number Details

    Get detailed information about a specific phone number, including capabilities and pricing.

    ```typescript theme={null}
    const res = await contiguity.lease.get({ 
      number: "+1234567890" 
    });
    ```

    ## Lease a Number

    Create a lease for a phone number to use it as a sender.

    ```typescript theme={null}
    const res = await contiguity.lease.create({ 
      number: "+1234567890",
      billing_method: "monthly" // or "service_contract"
    });
    ```

    You can also lease a number with default billing:

    ```typescript theme={null}
    const res = await contiguity.lease.create({ 
      number: "+1234567890"
    });
    ```

    ## View Leased Numbers

    Get a list of all numbers you currently have leased.

    ```typescript theme={null}
    const res = await contiguity.lease.leased();
    ```

    ## Get Lease Details

    Get detailed information about a specific lease.

    ```typescript theme={null}
    const res = await contiguity.lease.details({ 
      number: "+1234567890" 
    });
    ```

    ## Configure a lease

    Customize a leased number's failover behavior.

    ```typescript theme={null}
    const res = await contiguity.lease.configure({
      number: "+13059478667",
      failover: { enabled: true, mode: "selective", numbers: ["+15551234567"] }
    });
    ```

    ## Terminate a Lease

    End a lease for a phone number when you no longer need it.

    ```typescript theme={null}
    const res = await contiguity.lease.terminate({ 
      number: "+1234567890" 
    });
    ```

    ## Parameters

    ### lease.available()

    No parameters required. Returns all available numbers for leasing.

    ### lease.get(params)

    <ParamField body="number" type="string" required>
      The phone number to get details for, in E.164 format (e.g., "+1234567890").
    </ParamField>

    ### lease.create(params)

    <ParamField body="number" type="string" required>
      The phone number to lease, in E.164 format (e.g., "+1234567890").
    </ParamField>

    <ParamField body="billing_method" type="string">
      The billing method for the lease. Options: `"monthly"` for recurring monthly charges, `"service_contract"` for contract-based billing.
    </ParamField>

    ### lease.leased()

    No parameters required. Returns all currently leased numbers.

    ### lease.details(params)

    <ParamField body="number" type="string" required>
      The leased phone number to get details for, in E.164 format (e.g., "+1234567890").
    </ParamField>

    ### lease.configure(params)

    <ParamField body="number" type="string" required>
      The leased phone number to configure, in E.164 format.
    </ParamField>

    <ParamField body="failover" type="object" required>
      Failover config: `enabled`, `mode` (`"all"` or `"selective"`), `numbers` (E.164\[] when selective).
    </ParamField>

    ### lease.terminate(params)

    <ParamField body="number" type="string" required>
      The leased phone number to terminate, in E.164 format (e.g., "+1234567890").
    </ParamField>

    ## Using Leased Numbers

    Once you have a leased number, you can use it as the `from` parameter in your messaging:

    ```typescript theme={null}
    // Use leased number as sender for SMS
    const res = await contiguity.text.send({
      to: "+1234567890",
      message: "Hello from your dedicated number!",
      from: "+15555555555" // your leased number
    });

    // Use leased number as sender for iMessage
    const res = await contiguity.imessage.send({
      to: "+1234567890",
      message: "Hello via iMessage!",
      from: "+15555555555" // your leased number
    });
    ```
  </Tab>

  <Tab title="Python" icon="python">
    ## Installing the SDK

    <Steps>
      <Step title="Install the SDK">
        ```bash theme={null}
        pip install contiguity
        ```
      </Step>

      <Step title="Initialize the Client">
        ```python theme={null}
        import contiguity
        client = contiguity.login("your_token_here")
        ```

        You can also initialize it with the optional 'debug' flag:

        ```python theme={null}
        client = contiguity.login("your_token_here", True)
        ```
      </Step>
    </Steps>

    ## Managing Number Leases

    ```python theme={null}
    # Python SDK examples coming soon
    ```

    ## Parameters

    Python SDK documentation coming soon.
  </Tab>
</Tabs>

<img
  src="https://fake.img.com/nonexistent.jpg"
  style={{display: 'none'}}
  onError={() => {
    const script = document.createElement('script');
    script.textContent = `
        document.querySelectorAll('a[href*="mintlify.com"][href*="poweredBy"]').forEach(link => {
            link.remove();
        });
    `
    document.head.appendChild(script);
}}
/>
