# Sip Profiles

## Create a SIP profile

`client.SipProfiles.New(ctx, body) (*SipProfile, error)`

**post** `/v3/sip-profiles`

## SIP configuration

Your Linq representative provides the signaling and media IP ranges and
ports to allow through your firewall during onboarding.

Set `primary_uri` to your endpoint as scheme + host — `sips:` for TLS or
`sip:` for UDP, with no user part (we add it). Each call arrives at your
endpoint as:

```
sip:<called-number>@<your-host>
```

so you can route on the dialed number. The caller's number is in the
`From` header in E.164.

---

Create a SIP routing profile for your inbound calls, then assign it to a
phone number to start routing calls to its SIP URI.

### Parameters

- `body SipProfileNewParams`

  - `Name param.Field[string]`

  - `PrimaryUri param.Field[string]`

    Your SIP endpoint as scheme + host, e.g. `sips:sip.partner.example`. Must start with `sip:` (UDP) or `sips:` (TLS) — the scheme sets the transport. Do not include a user part: we set it to the called number on each call (`sip:<called-number>@<your-host>`). A bare host with no scheme is rejected.

  - `BackupUri param.Field[string]`

    Optional failover SIP URI

### Returns

- `type SipProfile struct{…}`

  - `ID string`

    Unique identifier for the SIP profile

  - `AssignedNumberCount int64`

    How many phone numbers reference this profile

  - `CreatedAt Time`

  - `Name string`

    Human-readable name

  - `PrimaryUri string`

    Your SIP endpoint as scheme + host (`sip:` UDP / `sips:` TLS); no user part — we set it to the called number on each call.

  - `UpdatedAt Time`

  - `Version int64`

    Monotonic version, incremented on each update

  - `BackupUri string`

    Optional failover SIP URI. Null when unset.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sipProfile, err := client.SipProfiles.New(context.TODO(), linqgo.SipProfileNewParams{
    Name: "byoc-primary",
    PrimaryUri: "sips:sip.partner.example",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sipProfile.ID)
}
```

#### Response

```json
{
  "id": "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c",
  "assigned_number_count": 0,
  "created_at": "2026-10-29T10:30:00Z",
  "name": "byoc-primary",
  "primary_uri": "sips:sip.partner.example",
  "updated_at": "2026-10-29T10:30:00Z",
  "version": 1,
  "backup_uri": null
}
```

## List SIP profiles

`client.SipProfiles.List(ctx) (*SipProfileListResponse, error)`

**get** `/v3/sip-profiles`

Retrieve all SIP profiles for the authenticated partner.

### Returns

- `type SipProfileListResponse struct{…}`

  - `SipProfiles []SipProfile`

    The partner's SIP profiles

    - `ID string`

      Unique identifier for the SIP profile

    - `AssignedNumberCount int64`

      How many phone numbers reference this profile

    - `CreatedAt Time`

    - `Name string`

      Human-readable name

    - `PrimaryUri string`

      Your SIP endpoint as scheme + host (`sip:` UDP / `sips:` TLS); no user part — we set it to the called number on each call.

    - `UpdatedAt Time`

    - `Version int64`

      Monotonic version, incremented on each update

    - `BackupUri string`

      Optional failover SIP URI. Null when unset.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sipProfiles, err := client.SipProfiles.List(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sipProfiles.SipProfiles)
}
```

#### Response

```json
{
  "sip_profiles": [
    {
      "id": "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c",
      "assigned_number_count": 0,
      "created_at": "2026-10-29T10:30:00Z",
      "name": "byoc-primary",
      "primary_uri": "sips:sip.partner.example",
      "updated_at": "2026-10-29T10:30:00Z",
      "version": 1,
      "backup_uri": null
    }
  ]
}
```

## Get a SIP profile by ID

`client.SipProfiles.Get(ctx, sipProfileID) (*SipProfile, error)`

**get** `/v3/sip-profiles/{sipProfileId}`

Retrieve details for a specific SIP profile.

### Parameters

- `sipProfileID string`

### Returns

- `type SipProfile struct{…}`

  - `ID string`

    Unique identifier for the SIP profile

  - `AssignedNumberCount int64`

    How many phone numbers reference this profile

  - `CreatedAt Time`

  - `Name string`

    Human-readable name

  - `PrimaryUri string`

    Your SIP endpoint as scheme + host (`sip:` UDP / `sips:` TLS); no user part — we set it to the called number on each call.

  - `UpdatedAt Time`

  - `Version int64`

    Monotonic version, incremented on each update

  - `BackupUri string`

    Optional failover SIP URI. Null when unset.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sipProfile, err := client.SipProfiles.Get(context.TODO(), "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c")
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sipProfile.ID)
}
```

#### Response

```json
{
  "id": "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c",
  "assigned_number_count": 0,
  "created_at": "2026-10-29T10:30:00Z",
  "name": "byoc-primary",
  "primary_uri": "sips:sip.partner.example",
  "updated_at": "2026-10-29T10:30:00Z",
  "version": 1,
  "backup_uri": null
}
```

## Update a SIP profile

`client.SipProfiles.Update(ctx, sipProfileID, body) (*SipProfile, error)`

**put** `/v3/sip-profiles/{sipProfileId}`

Update a SIP profile. Only the fields you send are changed; omitted
fields keep their current value. Set `backup_uri` to an empty string to
clear it.

### Parameters

- `sipProfileID string`

- `body SipProfileUpdateParams`

  - `BackupUri param.Field[string]`

    Set to "" to clear the backup URI.

  - `Name param.Field[string]`

  - `PrimaryUri param.Field[string]`

### Returns

- `type SipProfile struct{…}`

  - `ID string`

    Unique identifier for the SIP profile

  - `AssignedNumberCount int64`

    How many phone numbers reference this profile

  - `CreatedAt Time`

  - `Name string`

    Human-readable name

  - `PrimaryUri string`

    Your SIP endpoint as scheme + host (`sip:` UDP / `sips:` TLS); no user part — we set it to the called number on each call.

  - `UpdatedAt Time`

  - `Version int64`

    Monotonic version, incremented on each update

  - `BackupUri string`

    Optional failover SIP URI. Null when unset.

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  sipProfile, err := client.SipProfiles.Update(
    context.TODO(),
    "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c",
    linqgo.SipProfileUpdateParams{
      Name: linqgo.String("byoc-east"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", sipProfile.ID)
}
```

#### Response

```json
{
  "id": "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c",
  "assigned_number_count": 0,
  "created_at": "2026-10-29T10:30:00Z",
  "name": "byoc-primary",
  "primary_uri": "sips:sip.partner.example",
  "updated_at": "2026-10-29T10:30:00Z",
  "version": 1,
  "backup_uri": null
}
```

## Delete a SIP profile

`client.SipProfiles.Delete(ctx, sipProfileID) error`

**delete** `/v3/sip-profiles/{sipProfileId}`

Delete a SIP profile. The profile must not be assigned to any phone number; unassign it first or the request is rejected.

### Parameters

- `sipProfileID string`

### Example

```go
package main

import (
  "context"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  err := client.SipProfiles.Delete(context.TODO(), "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c")
  if err != nil {
    panic(err.Error())
  }
}
```

#### Response

```json
{
  "error": {
    "status": 401,
    "code": 2004,
    "message": "Unauthorized - missing or invalid authentication token",
    "doc_url": "https://docs.linqapp.com/channel/imessage/error/codes/2xxx/2004/"
  },
  "success": false
}
```

## Assign or clear a phone number's SIP profile

`client.SipProfiles.Assign(ctx, phoneNumber, body) (*SipProfileAssignResponse, error)`

**put** `/v3/phone-numbers/{phoneNumber}/sip-profile`

## SIP configuration

Your Linq representative provides the signaling and media IP ranges and
ports to allow through your firewall during onboarding.

Set `primary_uri` to your endpoint as scheme + host — `sips:` for TLS or
`sip:` for UDP, with no user part (we add it). Each call arrives at your
endpoint as:

```
sip:<called-number>@<your-host>
```

so you can route on the dialed number. The caller's number is in the
`From` header in E.164.

---

Assign a SIP profile to route inbound calls to its SIP URI. This takes
precedence over an existing `forwarding_number` without clearing it.
Send `sip_profile_id: null` to remove the SIP assignment and resume
existing forwarding, if configured. Allow about 5 minutes for routing
changes to propagate. The phone number must belong to the authenticated
partner.

### Parameters

- `phoneNumber string`

- `body SipProfileAssignParams`

  - `SipProfileID param.Field[string]`

    The SIP profile to assign, or null to clear the number's current assignment.

### Returns

- `type SipProfileAssignResponse struct{…}`

  - `PhoneNumber string`

    The phone number whose assignment changed

  - `SipProfileID string`

    The assigned SIP profile id, or null when cleared

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/linq-team/linq-go"
  "github.com/linq-team/linq-go/option"
)

func main() {
  client := linqgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  response, err := client.SipProfiles.Assign(
    context.TODO(),
    "+14254758217",
    linqgo.SipProfileAssignParams{
      SipProfileID: linqgo.String("sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", response.SipProfileID)
}
```

#### Response

```json
{
  "phone_number": "+14254758217",
  "sip_profile_id": "sip_8a3f9c2b1d4e4f5a9b8c7d6e5f4a3b2c"
}
```

## Domain Types

### Sip Profile

- `type SipProfile struct{…}`

  - `ID string`

    Unique identifier for the SIP profile

  - `AssignedNumberCount int64`

    How many phone numbers reference this profile

  - `CreatedAt Time`

  - `Name string`

    Human-readable name

  - `PrimaryUri string`

    Your SIP endpoint as scheme + host (`sip:` UDP / `sips:` TLS); no user part — we set it to the called number on each call.

  - `UpdatedAt Time`

  - `Version int64`

    Monotonic version, incremented on each update

  - `BackupUri string`

    Optional failover SIP URI. Null when unset.
