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

# Créer

> Liens — Créer. `POST /links`

Playground interactif pour `POST /links`.

<Tip>
  Collez votre clé API dans le champ Authorization : `Bearer {api_key}`.
</Tip>

<RequestExample dropdown>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.kloo.li/v1/links' \
    --header 'Authorization: Bearer {api_key}' \
    --header 'Content-Type: application/x-www-form-urlencoded' \
    --data 'example=value'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.kloo.li/v1/links', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer {api_key}',
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: 'example=value'
  });
  const data = await response.json();
  console.log(data);
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.kloo.li/v1/links', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer {api_key}',
      'Content-Type': 'application/x-www-form-urlencoded'
    },
    body: 'example=value'
  });
  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  url = 'https://api.kloo.li/v1/links'
  headers = {'Authorization': 'Bearer {api_key}'}
  data = {'example': 'value'}
  response = requests.request('POST', url, headers=headers, data=data)
  print(response.json())
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://api.kloo.li/v1/links');
  curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['Authorization: Bearer {api_key}'],
    CURLOPT_POSTFIELDS => http_build_query(['example' => 'value']),
  ]);
  echo curl_exec($ch);
  curl_close($ch);
  ```

  ```go Go theme={null}
  package main

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

  func main() {
    body := strings.NewReader("example=value")
    req, _ := http.NewRequest("POST", "https://api.kloo.li/v1/links", body)
    req.Header.Set("Authorization", "Bearer {api_key}")
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    data, _ := io.ReadAll(res.Body)
    fmt.Println(string(data))
  }
  ```

  ```java Java theme={null}
  HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.kloo.li/v1/links"))
    .header("Authorization", "Bearer {api_key}")
    .method("POST", HttpRequest.BodyPublishers.ofString("example=value"))
    .build();
  HttpResponse<String> response = HttpClient.newHttpClient()
    .send(request, HttpResponse.BodyHandlers.ofString());
  System.out.println(response.body());
  ```

  ```csharp C# theme={null}
  using var client = new HttpClient();
  client.DefaultRequestHeaders.Add("Authorization", "Bearer {api_key}");
  var content = new FormUrlEncodedContent(new Dictionary<string, string> { { "example", "value" } });
  var request = new HttpRequestMessage(HttpMethod.Post, "https://api.kloo.li/v1/links") { Content = content };
  var response = await client.SendAsync(request);
  Console.WriteLine(await response.Content.ReadAsStringAsync());
  ```

  ```ruby Ruby theme={null}
  require 'net/http'
  require 'uri'

  uri = URI('https://api.kloo.li/v1/links')
  req = Net::HTTP::Post.new(uri)
  req['Authorization'] = 'Bearer {api_key}'
  req.set_form_data('example' => 'value')
  res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(req) }
  puts res.body
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "data": {
      "id": 1
    }
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi.fr.yaml POST /links
openapi: 3.0.3
info:
  title: API publique Kloo
  version: 1.0.0
  description: API utilisateur Kloo — liens courts, codes QR, domaines, équipes, analytics.
servers:
  - url: https://api.kloo.li/v1
security:
  - bearerAuth: []
paths:
  /links:
    post:
      tags:
        - Liens
      summary: Créer (liens)
      operationId: links_create_post_links
      parameters: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                type:
                  type: string
                  enum:
                    - email
                    - webhook
                    - slack
                    - discord
                    - telegram
                    - microsoft_teams
                    - twilio
                    - twilio_call
                    - whatsapp
                    - x
                    - google_chat
                    - push_subscriber_id
                  description: 'Resource type (Default `link`; create: `link`|`static`)'
                location_url:
                  type: string
                  description: Destination URL (Valid URL w/ scheme)
                location_urls:
                  type: string
                  description: Bulk destinations (Newline-separated URLs)
                is_bulk:
                  type: boolean
                  description: Bulk mode (Presence = true)
                url:
                  type: string
                  description: Custom alias (empty = random) (Unique slug; ignored in bulk)
                domain_id:
                  type: integer
                  description: Domain id (Available domain; `0` = main)
                project_id:
                  type: integer
                  description: Project id (Owned by user)
                pixels_ids:
                  type: array
                  items:
                    type: integer
                  description: Tracking pixels (Owned pixels)
                email_reports:
                  type: array
                  items:
                    type: integer
                  description: Report handlers (Handler ids)
                is_enabled:
                  type: boolean
                  description: Enable link (Défaut `1`)
                schedule:
                  type: boolean
                  description: Enable schedule (Presence = true)
                start_date:
                  type: string
                  description: Start (`Y-m-d H:i:s`)
                end_date:
                  type: string
                  description: End (`Y-m-d H:i:s`)
                clicks_limit:
                  type: integer
                  description: Max clicks
                expiration_url:
                  type: string
                  description: After expiry redirect (URL or empty)
                sensitive_content:
                  type: boolean
                  description: Sensitive flag (Presence = true)
                http_status_code:
                  type: integer
                  enum:
                    - 301
                    - 302
                    - 307
                    - 308
                  description: >-
                    Redirect status (Default `301`; `301`|`302`|`307`|`308`).
                    Valeurs autorisées : `301`, `302`, `307`, `308`.
                app_linking_is_enabled:
                  type: boolean
                  description: App deep links (Presence = true)
                cloaking_is_enabled:
                  type: boolean
                  description: Cloaking (Presence = true)
                cloaking_title:
                  type: string
                  description: Cloaking title (Max 70)
                cloaking_meta_description:
                  type: string
                  description: Cloaking description (Max 160)
                cloaking_custom_js:
                  type: string
                  description: Custom JS (Max 10000)
                cloaking_favicon:
                  type: string
                  format: binary
                  description: Favicon file (Size limited)
                cloaking_opengraph:
                  type: string
                  format: binary
                  description: OG image (Size limited)
                password:
                  type: string
                  description: Visitor password (Max 64, hashed)
                forward_query_parameters_is_enabled:
                  type: boolean
                  description: Forward query string (Presence = true)
                seo_block:
                  type: boolean
                  description: noindex (Presence = true)
                utm_source:
                  type: string
                  description: UTM source (Max 128)
                utm_medium:
                  type: string
                  description: UTM medium (Max 128)
                utm_campaign:
                  type: string
                  description: UTM campaign (Max 128)
                targeting_type:
                  type: string
                  enum:
                    - continent_code
                    - country_code
                    - device_type
                    - browser_language
                    - rotation
                    - os_name
                    - browser_name
                  description: >-
                    Targeting mode (`false` or
                    `continent_code`|`country_code`|`city_name`|`device_type`|`browser_language`|`rotation`|`os_name`|`browser_name`).
                    Valeurs autorisées : `false`, `continent_code`,
                    `country_code`, `device_type`, `browser_language`,
                    `rotation`, `os_name`, `browser_name`, `city_name`.
                targeting_{type}_key[index]:
                  type: string
                  description: Rule key (When targeting on)
                targeting_{type}_value[index]:
                  type: string
                  description: Rule destination (Must be URL)
              required:
                - location_url
                - location_urls
      responses:
        '200':
          description: Succès
        '201':
          description: Créé
        '400':
          description: Requête invalide
        '401':
          description: Non autorisé
        '404':
          description: Introuvable
        '429':
          description: Limite de débit
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: '{api_key}'
      x-default: '{api_key}'
      description: >-
        Récupérez votre clé API sur https://kloo.li/account-api. Utilisez
        `Authorization: Bearer {api_key}`.

````