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

# Start a widget session

POST https://api.jelliu.co/widget/init
Content-Type: application/json

Opens (or resumes) a visitor session and returns what the chat UI needs to render: greeting, branding
and whether voice is on. Call it once when the chat loads, then use the returned `session_id` with
`POST /widget/message`, `GET /widget/poll` and `GET /widget/history`. The standard embed script does all
of this for you.

**Credentials.** This is a public endpoint. It does **not** accept a dashboard session or a `jl_` API key.
Name the widget with exactly one of these, checked in this order:
1. `x-widget-api-key` header: the secret `plaintext_api_key` (server-side callers only);
2. `x-widget-id` header: the public widget id (what the embed uses);
3. `wid` query parameter: the public widget id.

The API key is never accepted in the query string. A value that looks like a UUID is treated as a
widget id, whichever header carries it. Every call must also send `x-widget-parent-origin` with the
origin of the page that embeds the widget; it must match one of the widget's `allowed_origins`
(scheme and port exactly, hostname modulo one leading `www.`). The check does not use the browser's
`Origin` header, and CORS is open (`Access-Control-Allow-Origin` reflects any origin, no credentials).

**Sessions.** Sessions are keyed by `visitor_id`. If the same visitor had a session on this widget
that was active in the last 30 days, it is returned with `resumed: true` and any new `metadata` is
merged into it (keys are added or overwritten, never removed); otherwise a new session is created.
Send `metadata.email` (and `metadata.name`) to link the visitor's conversation to a contact.

**Side effects.** Creates or updates a `widget_sessions` row (with the caller's IP and user agent on
creation). No conversation is created until the first message; no AI usage is recorded.

**Idempotency.** Safe to retry with the same `visitor_id`: a retry resumes the session the first call
created. Two truly concurrent first calls for a new visitor can create two sessions.

**Access**
- **Required scope:** None; `jl_` API keys are not used. The widget credential plus a matching `x-widget-parent-origin` authorise the call.
- **Rate limit:** Widget public — 60 requests/min per IP, plus the widget's `rate_limit_rpm` (default 30) per credential and 300 requests/min per workspace across all its widgets; the general limiter also counts 120 requests/min per IP. See [Rate limits](/rate-limits).
- **Plan:** Available on every plan.


Reference: https://developer.jelliu.co/api-reference/widgets/post-widget-init

## Request

### Query parameters

- `wid` (string, optional) — Public widget id as a query parameter. Used when neither header is present.

### Headers

- `x-widget-api-key` (string, optional) — Secret widget API key (`plaintext_api_key` from `POST /api/widgets`). Takes precedence over `x-widget-id` and `wid`. Send one of the three. Never expose it in a browser.
- `x-widget-id` (string, optional) — Public widget id, the credential the embed script uses. Used when `x-widget-api-key` is absent.
- `x-widget-parent-origin` (string, required) — Origin (or any URL; only its origin is used) of the page embedding the widget. Must match one of the widget's `allowed_origins`. Missing returns 403; an unparseable value returns 403 `Invalid parent origin`. Only the dashboard preview, which sends a short-lived `x-widget-preview-token`, may omit it.

### Body (application/json)

This endpoint expects an object.

- `visitor_id` (string, required) — Stable id the embedding page keeps for this visitor (the embed stores a UUID in `localStorage`). Reusing it within 30 days resumes the same session and conversation.
- `metadata` (map from string to any, optional) — Free-form visitor data stored on the session (merged on resume). `email` links the conversation to a contact (created in the workspace's manual-conversations campaign if none matches, case-insensitively); `name` fills the contact's name when it is empty.

## Response

### 201

Session created or resumed (both return 201).

- `data` (object, required)
  - `session_id` (string, required) — Session id to pass to the message, poll and history endpoints.
  - `resumed` (boolean, required) — `true` when an existing session was reused; the UI should restore history with `GET /widget/history` instead of greeting again.
  - `greeting_message` (string, required, nullable) — The widget's greeting, or `null` when none is set.
  - `branding` (object, required) — Widget look and copy. On write, `primary_color` is required whenever `branding` is sent, and the object REPLACES the stored branding (it is not merged). Widgets created without branding store `{}`, which is what `POST /widget/init` then returns.
    - `primary_color` (string, required) — Accent colour for the launcher and header, as `#RRGGBB` (error: `Must be a hex color like #FF0000`).
    - `logo_url` (string, optional) — Logo shown in the chat header.
    - `position` (enum, optional) — Corner for the launcher button. `bottom-right` puts it in the lower-right corner (the default when omitted); `bottom-left` in the lower-left corner.
      - Allowed values: `bottom-right`, `bottom-left`
    - `title` (string, optional) — Chat header title.
    - `subtitle` (string, optional) — Line under the title, such as expected reply time.
    - `quick_replies` (list of string, optional) — Up to 4 suggestion chips shown under the greeting (1 to 60 characters each).
    - `agent_names` (list of string, optional) — Display names (1 to 40 characters); the UI picks one per visitor and replies are signed with it.
    - `agent_avatars` (list of string, optional) — One picture per entry of `agent_names`, aligned by index. `https://` URLs or site-relative paths only (up to 500 characters); other values fail with `La imagen debe ser https o una ruta propia`.
    - `i18n` (map from string to object, optional) — Per-language greeting and quick replies, keyed by primary language subtag (`es`, `en`). The widget uses the block matching the visitor's language before falling back to `greeting_message`.
      - `greeting` (string, optional) — Greeting for this language.
      - `quick_replies` (list of string, optional) — Quick replies for this language.
  - `voice_enabled` (boolean, required) — Whether the UI should offer voice (`POST /widget/voice-session`).

## Errors

### 400 Bad Request Error

`visitor_id` missing or empty, or `metadata` not an object. No field details are returned.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 401 Unauthorized Error

No credential (`Missing widget credential`), or the id/key matches no widget, including a deleted one (`Invalid widget API key`).

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 403 Forbidden Error

`Widget is deactivated`; `Service unavailable` (the workspace was deleted); `Widget has no allowed origins configured`; missing `x-widget-parent-origin`; `Invalid parent origin`; or `Origin not allowed`.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 429 Too Many Requests Error

A limit was hit: `Too many widget requests from this IP, please slow down` (per IP, with `Retry-After`), `Rate limit exceeded` (per widget or per workspace), or `Too many requests, please slow down` (general per-IP limiter).

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

### 503 Service Unavailable Error

The per-widget limiter's store is unreachable; it fails closed.

- `error` (object, required) — The error object. Always has `code` and `message`.
  - `code` (string, required) — Stable machine-readable error code (for example `VALIDATION_FAILED`, `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `BILLING_ERROR`, `COMPLIANCE_BLOCKED`, `RATE_LIMIT_EXCEEDED`, `INTERNAL_ERROR`). Switch on this, not on `message`. See [Errors](/errors).
  - `message` (string, required) — Human-readable explanation. English or Spanish depending on the route; may change without notice.
  - `details` (object or list of object, optional) — Present on `VALIDATION_FAILED` only. Its shape depends on how the route validates: * a field map, either Zod's `flatten()` output (`{ "formErrors": [], "fieldErrors": { "name": ["..."] } }`) or just its `fieldErrors` part (`{ "name": ["..."] }`); * an issue list, where each issue has at least `path`, `message` and `code`. `path` is a dot-separated string on routes that let the schema throw, and an array of keys on routes that forward Zod's raw issues (those also carry Zod's extra issue fields).
    - Field map
      - `formErrors` (list of string, optional)
      - `fieldErrors` (map from string to list of string, optional)
  - `metadata` (map from string to any, optional) — Structured detail exposed for a small allowlist of codes only — for example `BILLING_ERROR` carries `limit`, `current` and `tier` (resource caps) or `tier` and `feature` (feature gates).

## Examples

### Widgets_postWidgetInit_example

**Request**

```json
undefined
```

**Response**

```json
{
  "data": {
    "session_id": "b3e227dd-a9ea-48ce-9afe-09c21a5d8d2d",
    "resumed": false,
    "greeting_message": "¡Hola! ¿En qué te puedo ayudar hoy?",
    "branding": {
      "primary_color": "#1C1D2B",
      "position": "bottom-right",
      "title": "Habla con nosotros",
      "quick_replies": [
        "Agendar una cita",
        "Ver precios"
      ],
      "agent_names": [
        "Laura",
        "Andrés"
      ]
    },
    "voice_enabled": true
  }
}
```

**SDK Code**

```python Widgets_postWidgetInit_example
import requests

url = "https://api.jelliu.co/widget/init"

querystring = {"wid":"84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e"}

headers = {
    "x-widget-api-key": "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284",
    "x-widget-id": "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e",
    "x-widget-parent-origin": "https://www.clinicasonrisa.co"
}

response = requests.post(url, headers=headers, params=querystring)

print(response.json())
```

```javascript Widgets_postWidgetInit_example
const url = 'https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e';
const options = {
  method: 'POST',
  headers: {
    'x-widget-api-key': '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284',
    'x-widget-id': '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e',
    'x-widget-parent-origin': 'https://www.clinicasonrisa.co'
  }
};

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

```go Widgets_postWidgetInit_example
package main

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

func main() {

	url := "https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e"

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

	req.Header.Add("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284")
	req.Header.Add("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
	req.Header.Add("x-widget-parent-origin", "https://www.clinicasonrisa.co")

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

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

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

}
```

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

url = URI("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")

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

request = Net::HTTP::Post.new(url)
request["x-widget-api-key"] = '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284'
request["x-widget-id"] = '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e'
request["x-widget-parent-origin"] = 'https://www.clinicasonrisa.co'

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

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

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
  .header("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284")
  .header("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
  .header("x-widget-parent-origin", "https://www.clinicasonrisa.co")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e', [
  'headers' => [
    'x-widget-api-key' => '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284',
    'x-widget-id' => '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e',
    'x-widget-parent-origin' => 'https://www.clinicasonrisa.co',
  ],
]);

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

```csharp Widgets_postWidgetInit_example
using RestSharp;

var client = new RestClient("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e");
var request = new RestRequest(Method.POST);
request.AddHeader("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284");
request.AddHeader("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e");
request.AddHeader("x-widget-parent-origin", "https://www.clinicasonrisa.co");
IRestResponse response = client.Execute(request);
```

```swift Widgets_postWidgetInit_example
import Foundation

let headers = [
  "x-widget-api-key": "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284",
  "x-widget-id": "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e",
  "x-widget-parent-origin": "https://www.clinicasonrisa.co"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

### Anonymous visitor

**Request**

```json
{
  "visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f"
}
```

**Response**

```json
{
  "data": {
    "session_id": "b3e227dd-a9ea-48ce-9afe-09c21a5d8d2d",
    "resumed": false,
    "greeting_message": "¡Hola! ¿En qué te puedo ayudar hoy?",
    "branding": {
      "primary_color": "#1C1D2B",
      "position": "bottom-right",
      "title": "Habla con nosotros",
      "quick_replies": [
        "Agendar una cita",
        "Ver precios"
      ],
      "agent_names": [
        "Laura",
        "Andrés"
      ]
    },
    "voice_enabled": true
  }
}
```

**SDK Code**

```python Anonymous visitor
import requests

url = "https://api.jelliu.co/widget/init"

querystring = {"wid":"84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e"}

payload = { "visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f" }
headers = {
    "x-widget-api-key": "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284",
    "x-widget-id": "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e",
    "x-widget-parent-origin": "https://www.clinicasonrisa.co",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript Anonymous visitor
const url = 'https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e';
const options = {
  method: 'POST',
  headers: {
    'x-widget-api-key': '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284',
    'x-widget-id': '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e',
    'x-widget-parent-origin': 'https://www.clinicasonrisa.co',
    'Content-Type': 'application/json'
  },
  body: '{"visitor_id":"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f"}'
};

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

```go Anonymous visitor
package main

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

func main() {

	url := "https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e"

	payload := strings.NewReader("{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\"\n}")

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

	req.Header.Add("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284")
	req.Header.Add("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
	req.Header.Add("x-widget-parent-origin", "https://www.clinicasonrisa.co")
	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 Anonymous visitor
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")

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

request = Net::HTTP::Post.new(url)
request["x-widget-api-key"] = '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284'
request["x-widget-id"] = '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e'
request["x-widget-parent-origin"] = 'https://www.clinicasonrisa.co'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
  .header("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284")
  .header("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
  .header("x-widget-parent-origin", "https://www.clinicasonrisa.co")
  .header("Content-Type", "application/json")
  .body("{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e', [
  'body' => '{
  "visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-widget-api-key' => '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284',
    'x-widget-id' => '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e',
    'x-widget-parent-origin' => 'https://www.clinicasonrisa.co',
  ],
]);

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

```csharp Anonymous visitor
using RestSharp;

var client = new RestClient("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e");
var request = new RestRequest(Method.POST);
request.AddHeader("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284");
request.AddHeader("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e");
request.AddHeader("x-widget-parent-origin", "https://www.clinicasonrisa.co");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Anonymous visitor
import Foundation

let headers = [
  "x-widget-api-key": "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284",
  "x-widget-id": "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e",
  "x-widget-parent-origin": "https://www.clinicasonrisa.co",
  "Content-Type": "application/json"
]
let parameters = ["visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f"] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")! 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()
```

### Signed-in visitor linked to a contact

**Request**

```json
{
  "visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f",
  "metadata": {
    "email": "maria.gomez@gmail.com",
    "name": "María Gómez"
  }
}
```

**Response**

```json
{
  "data": {
    "session_id": "b3e227dd-a9ea-48ce-9afe-09c21a5d8d2d",
    "resumed": false,
    "greeting_message": "¡Hola! ¿En qué te puedo ayudar hoy?",
    "branding": {
      "primary_color": "#1C1D2B",
      "position": "bottom-right",
      "title": "Habla con nosotros",
      "quick_replies": [
        "Agendar una cita",
        "Ver precios"
      ],
      "agent_names": [
        "Laura",
        "Andrés"
      ]
    },
    "voice_enabled": true
  }
}
```

**SDK Code**

```python Signed-in visitor linked to a contact
import requests

url = "https://api.jelliu.co/widget/init"

querystring = {"wid":"84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e"}

payload = {
    "visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f",
    "metadata": {
        "email": "maria.gomez@gmail.com",
        "name": "María Gómez"
    }
}
headers = {
    "x-widget-api-key": "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284",
    "x-widget-id": "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e",
    "x-widget-parent-origin": "https://www.clinicasonrisa.co",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, params=querystring)

print(response.json())
```

```javascript Signed-in visitor linked to a contact
const url = 'https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e';
const options = {
  method: 'POST',
  headers: {
    'x-widget-api-key': '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284',
    'x-widget-id': '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e',
    'x-widget-parent-origin': 'https://www.clinicasonrisa.co',
    'Content-Type': 'application/json'
  },
  body: '{"visitor_id":"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f","metadata":{"email":"maria.gomez@gmail.com","name":"María Gómez"}}'
};

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

```go Signed-in visitor linked to a contact
package main

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

func main() {

	url := "https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e"

	payload := strings.NewReader("{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\",\n  \"metadata\": {\n    \"email\": \"maria.gomez@gmail.com\",\n    \"name\": \"María Gómez\"\n  }\n}")

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

	req.Header.Add("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284")
	req.Header.Add("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
	req.Header.Add("x-widget-parent-origin", "https://www.clinicasonrisa.co")
	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 Signed-in visitor linked to a contact
require 'uri'
require 'net/http'

url = URI("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")

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

request = Net::HTTP::Post.new(url)
request["x-widget-api-key"] = '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284'
request["x-widget-id"] = '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e'
request["x-widget-parent-origin"] = 'https://www.clinicasonrisa.co'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\",\n  \"metadata\": {\n    \"email\": \"maria.gomez@gmail.com\",\n    \"name\": \"María Gómez\"\n  }\n}"

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

```java Signed-in visitor linked to a contact
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
  .header("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284")
  .header("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")
  .header("x-widget-parent-origin", "https://www.clinicasonrisa.co")
  .header("Content-Type", "application/json")
  .body("{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\",\n  \"metadata\": {\n    \"email\": \"maria.gomez@gmail.com\",\n    \"name\": \"María Gómez\"\n  }\n}")
  .asString();
```

```php Signed-in visitor linked to a contact
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e', [
  'body' => '{
  "visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f",
  "metadata": {
    "email": "maria.gomez@gmail.com",
    "name": "María Gómez"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-widget-api-key' => '3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284',
    'x-widget-id' => '84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e',
    'x-widget-parent-origin' => 'https://www.clinicasonrisa.co',
  ],
]);

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

```csharp Signed-in visitor linked to a contact
using RestSharp;

var client = new RestClient("https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e");
var request = new RestRequest(Method.POST);
request.AddHeader("x-widget-api-key", "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284");
request.AddHeader("x-widget-id", "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e");
request.AddHeader("x-widget-parent-origin", "https://www.clinicasonrisa.co");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"visitor_id\": \"4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f\",\n  \"metadata\": {\n    \"email\": \"maria.gomez@gmail.com\",\n    \"name\": \"María Gómez\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Signed-in visitor linked to a contact
import Foundation

let headers = [
  "x-widget-api-key": "3462145765a6b6c238f79a1e13e10361c24d1740ec30d27bea22dd4106c04284",
  "x-widget-id": "84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e",
  "x-widget-parent-origin": "https://www.clinicasonrisa.co",
  "Content-Type": "application/json"
]
let parameters = [
  "visitor_id": "4c1f8e2a-9b7d-4a6e-8f3c-2d1b0a9e8c7f",
  "metadata": [
    "email": "maria.gomez@gmail.com",
    "name": "María Gómez"
  ]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.jelliu.co/widget/init?wid=84b5aa0e-f6d6-4d88-b3ad-cd7a5a2aeb9e")! 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()
```