> ## 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 un site statique

> Liens et pages — Créer un site statique. `POST /links`

Publiez un site statique depuis un fichier `.html` ou une archive `.zip`. Le site publié doit inclure `index.html` à la racine de déploiement.

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

<ParamField body="type" type="string" required>
  Doit être `static`.
</ParamField>

<ParamField body="name" type="string" required>
  Nom d’affichage du site (128 caractères max).
</ParamField>

<ParamField body="file" type="file" required>
  Uploadez un `.html` (stocké comme `index.html`) ou un `.zip` avec un `index.html` déployable à la racine.
</ParamField>

<ParamField body="url" type="string">
  Alias personnalisé. Vide = aléatoire.
</ParamField>

<ParamField body="domain_id" type="integer">
  ID du domaine. `0` = domaine principal.
</ParamField>

<ParamField body="project_id" type="integer">
  ID du projet appartenant à l’utilisateur authentifié.
</ParamField>

<ParamField body="is_enabled" type="boolean">
  Activer le site. Défaut : `1`.
</ParamField>

<ParamField body="password" type="string">
  Mot de passe visiteur optionnel (64 caractères max).
</ParamField>

<RequestExample dropdown>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.kloo.li/v1/links' \
    --header 'Authorization: Bearer {api_key}' \
    --header 'Content-Type: multipart/form-data' \
    --form 'type=static' \
    --form 'name=My landing' \
    --form 'file=@/path/to/site.zip'
  ```

  ```javascript JavaScript theme={null}
  const formData = new FormData();
  formData.append('type', 'static');
  formData.append('name', 'My landing');
  formData.append('file', '@/path/to/site.zip');

  const response = await fetch('https://api.kloo.li/v1/links', {
    method: 'POST',
    headers: { Authorization: 'Bearer {api_key}' },
    body: formData
  });
  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 = {
      'type': 'static',
      'name': 'My landing',
      'file': '@/path/to/site.zip'
  }
  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 => [
      'type' => 'static',
      'name' => 'My landing',
      'file' => '@/path/to/site.zip'
    ],
  ]);
  echo curl_exec($ch);
  curl_close($ch);
  ```

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

  import (
    "bytes"
    "fmt"
    "io"
    "mime/multipart"
    "net/http"
  )

  func main() {
    var body bytes.Buffer
    writer := multipart.NewWriter(&body)
    _ = writer.WriteField("type", "static")
    _ = writer.WriteField("name", "My landing")
    _ = writer.WriteField("file", "@/path/to/site.zip")
    _ = writer.Close()
    req, _ := http.NewRequest("POST", "https://api.kloo.li/v1/links", &body)
    req.Header.Set("Authorization", "Bearer {api_key}")
    req.Header.Set("Content-Type", writer.FormDataContentType())
    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}")
    .header("Content-Type", "application/x-www-form-urlencoded")
    .method("POST", HttpRequest.BodyPublishers.ofString("type=static&name=My landing&file=@/path/to/site.zip"))
    .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> { { "type", "static" }, { "name", "My landing" }, { "file", "@/path/to/site.zip" } });
  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('type' => 'static', 'name' => 'My landing', 'file' => '@/path/to/site.zip')
  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": 12,
      "type": "static",
      "url": "abc12xy",
      "settings": {
        "name": "My landing"
      },
      "additional": {
        "mode": "file",
        "static_folder": "...",
        "files": [
          "index.html"
        ],
        "total_files": 1
      }
    }
  }
  ```
</ResponseExample>
