> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.jambonz.org/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.jambonz.org/_mcp/server.

# Client Authentication

POST https://{yourserver}/webhooks/auth
Content-Type: application/json

This webhook is sent when a SIP client tries to authenticate, it is configured at the account level

Reference: https://docs.jambonz.org/reference/webhooks/registration-hook-post

## Authentication

- `Authorization` header (basic auth, required) — Basic authentication of the form `Basic <base64(username:password)>`.

## Request

### Body (application/json)

This endpoint expects an object.

- `method` (string, required) — sip request method
- `realm` (string, required) — sip realm
- `username` (string, required) — sip username provided
- `expires` (double, required) — expiration requested, in seconds
- `nonce` (string, required) — nonce value
- `uri` (string, required) — sip uri in request
- `response` (string, required) — digest value calculated by the client
- `scheme` (string, optional) — encryption protocol
- `algorithm` (string, optional) — encryption algorithm used, default to MD5 if not provided
- `qop` (string, optional) — qop value
- `cnonce` (string, optional) — cnonce value
- `nc` (string, optional) — nc value

## Response

### 200

Your callback should return this HTTP status code in all cases. if the request was authenticated and you wish to admit the client to the network, this is indicated by setting the 'status' attribute in the body to 'ok'

- `status` (enum, required) — indicates whether the request was successfully authenticated
  - Allowed values: `ok`, `fail`
- `message` (string, optional) — a human-readable message
- `application_sid` (string, optional) — sid of application to invoke when this device places a call
- `expires` (double, optional) — The expires value to grant to the requesting user. If not provided, the expires value in the request is observed. If provided, must be less than the requested expires value.
- `blacklist` (double, optional) — If provided, represents a period in seconds during which the source IP address should be blacklisted by the platform (0 means forever).

## Examples

**Request**

```json
{
  "method": "REGISTER",
  "realm": "mycompany.com",
  "username": "daveh",
  "expires": 3600,
  "nonce": "InFriVGWVoKeCckYrTx7wg==\"",
  "uri": "sip:mycompany.com",
  "response": "be641cf7951ff23ab04c57907d59f37d"
}
```

**Response**

```json
{
  "status": "ok",
  "message": "authentication granted",
  "application_sid": "string",
  "expires": 1.1,
  "blacklist": 1.1
}
```

**SDK Code**

```python
import requests

url = "https://{yourserver}/webhooks/auth"

payload = {
    "method": "REGISTER",
    "realm": "mycompany.com",
    "username": "daveh",
    "expires": 3600,
    "nonce": "InFriVGWVoKeCckYrTx7wg==\"",
    "uri": "sip:mycompany.com",
    "response": "be641cf7951ff23ab04c57907d59f37d"
}
headers = {
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

```javascript
const url = 'https://{yourserver}/webhooks/auth';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{"method":"REGISTER","realm":"mycompany.com","username":"daveh","expires":3600,"nonce":"InFriVGWVoKeCckYrTx7wg==\"","uri":"sip:mycompany.com","response":"be641cf7951ff23ab04c57907d59f37d"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://{yourserver}/webhooks/auth"

	payload := strings.NewReader("{\n  \"method\": \"REGISTER\",\n  \"realm\": \"mycompany.com\",\n  \"username\": \"daveh\",\n  \"expires\": 3600,\n  \"nonce\": \"InFriVGWVoKeCckYrTx7wg==\\\"\",\n  \"uri\": \"sip:mycompany.com\",\n  \"response\": \"be641cf7951ff23ab04c57907d59f37d\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.SetBasicAuth("<username>", "<password>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://{yourserver}/webhooks/auth")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{\n  \"method\": \"REGISTER\",\n  \"realm\": \"mycompany.com\",\n  \"username\": \"daveh\",\n  \"expires\": 3600,\n  \"nonce\": \"InFriVGWVoKeCckYrTx7wg==\\\"\",\n  \"uri\": \"sip:mycompany.com\",\n  \"response\": \"be641cf7951ff23ab04c57907d59f37d\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://{yourserver}/webhooks/auth")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{\n  \"method\": \"REGISTER\",\n  \"realm\": \"mycompany.com\",\n  \"username\": \"daveh\",\n  \"expires\": 3600,\n  \"nonce\": \"InFriVGWVoKeCckYrTx7wg==\\\"\",\n  \"uri\": \"sip:mycompany.com\",\n  \"response\": \"be641cf7951ff23ab04c57907d59f37d\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://{yourserver}/webhooks/auth', [
  'body' => '{
  "method": "REGISTER",
  "realm": "mycompany.com",
  "username": "daveh",
  "expires": 3600,
  "nonce": "InFriVGWVoKeCckYrTx7wg==\\"",
  "uri": "sip:mycompany.com",
  "response": "be641cf7951ff23ab04c57907d59f37d"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://{yourserver}/webhooks/auth");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"method\": \"REGISTER\",\n  \"realm\": \"mycompany.com\",\n  \"username\": \"daveh\",\n  \"expires\": 3600,\n  \"nonce\": \"InFriVGWVoKeCckYrTx7wg==\\\"\",\n  \"uri\": \"sip:mycompany.com\",\n  \"response\": \"be641cf7951ff23ab04c57907d59f37d\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = [
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [
  "method": "REGISTER",
  "realm": "mycompany.com",
  "username": "daveh",
  "expires": 3600,
  "nonce": "InFriVGWVoKeCckYrTx7wg==\"",
  "uri": "sip:mycompany.com",
  "response": "be641cf7951ff23ab04c57907d59f37d"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://{yourserver}/webhooks/auth")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```