Skip to content

Session create

This endpoint creates or returns a user session.

API key

You must add the x-api-key: your-api-key from the admin panel settings to the headers

Endpoint

POST https://api.kod.mobi/session/create

Request

JSON body

SessionCreateBody

Param Type Description Default Required
to phone (E.164) | email Mobile phone number in
international format or email address
- true
type Channel Channel type A channel that the user has already used
or is set as default in the admin panel
false
send boolean Should we send or just create true false

Session expiration

Session valid 3 minutes

Response

SessionCreateResponse

Param Type Description
session_id ulid Session id
session_expired_at string | datetime Session expired datetime
sent_to Channel Channel type
channels array | []SessionChannel Session available channels

Example

1
2
3
4
5
6
7
curl --location 'https://api.kod.mobi/session/create' \
    --header 'x-api-key: <replace me>' \
    --data '{
        "to": <replace me>,
        "type": "telegram",
        "send": true
    }'
const headers = new Headers();
myHeaders.append("x-api-key", "<replace me>");

const raw = JSON.stringify({
  "to": "<replace me>",
  "type": "telegram",
  "send": true
});

const requestOptions: RequestInit = {
  method: "POST",
  headers,
  body: raw,
  redirect: "follow"
};

fetch("https://api.kod.mobi/session/create", requestOptions)
  .then((response) => response.json())
  .then((result) => console.log(result))
  .catch((error) => console.error(error));
<?php

$client = new \GuzzleHttp\Client(); 
$headers = [
  'x-api-key' => '<replace me>'
];

$body = '{
  "to": "<replace me>",
  "type": "telegram",
  "send": true
}';

$request = new Request('POST', 'https://api.kod.mobi/session/create', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
package main

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

func main() {
  payload := strings.NewReader(`{
    "to": "<replace me>",
    "type": "telegram",
    "send": true
  }`)

  client := &http.Client {}
  req, err := http.NewRequest("POST", "https://api.kod.mobi/session/create", payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("x-api-key", "<replace me>")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::builder()
        .build()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("x-api-key", "<replace me>".into());

    let data = r#"{
        "to": "<replace me>",
        "type": "telegram",
        "send": true
    }"#;

    let json: serde_json::Value = serde_json::from_str(&data)?;

    let request = client.request(reqwest::Method::POST, "https://api.kod.mobi/session/create")
        .headers(headers)
        .json(&json);

    let response = request.send().await?;
    let body = response.text().await?;

    println!("{}", body);

    Ok(())
}

Example output

{
  "session_id": "01K8N1VMPN0EE389K72YW0CBM2",
  "session_expired_at": "2025-10-28T09:22:48.950Z",
  "sent_to": "telegram",
  "channels": [
    {
      "name": "Whatsapp",
      "type": "whatsapp",
      "is_active": true,
      "timeout": 0,
      "image_url": "https://storage.kod.mobi/icons/whatsapp.svg",
      "link": "https://kod.mobi"
    },
    {
      "name": "Telegram",
      "type": "telegram",
      "is_active": false,
      "timeout": 60,
      "image_url": "https://storage.kod.mobi/icons/telegram.svg",
      "link": "https://t.me/my-tg-bot"
    },
    {
      "name": "SMS",
      "type": "sms",
      "is_active": false,
      "timeout": 0,
      "image_url": "https://storage.kod.mobi/icons/sms.svg",
      "link": "https://kod.mobi"
    }
  ]
}