API documentation Web hosting accessible to everyone Visit LWS

Buying an hosting/domain

Deferred Paid action

POST https://api.lws.net/v1/hosting

operationIdpostHostingBuy

Buy a domain or an hosting on your account. 'package' is the name of the hosting to buy (choose 'domaine' to buy only the domain).

This request is processed in the background: it answers immediately while the work continues. Follow it with the task or request endpoints.

This is a paid action. Your prepaid account will be debited.

Request body

  • package string

    Which hosting to buy among all LWS hostings

    Example: LWS Perso

    optional
  • domain string

    Domain name to associate the hosting to

    Example: example.com

    optional
  • owner integer

    Owner of the hosting

    Example: 565487

    optional
  • type string

    All options will buy the selected hosting. 'buy' will also purchase the domain ; 'host' will only buy the hosting, assuming you already possess the domain ; 'transfer' will transfer an existing domain from another registrar to LWS.

    Example: buy

    optional
  • period integer

    Period of the hosting

    Example: 12

    optional
Example request
{
  "package": "LWS Perso",
  "domain": "example.com",
  "owner": 565487,
  "type": "buy",
  "period": 12
}

Responses

200

Hosting created successfully

{
  "code": 200,
  "info": "Your domain example.com has been bought with the hosting LWS Perso.",
  "data": []
}
Response fields 3
  • code integer

    Example: 200

  • info string

    Example: Your domain example.com has been bought with the hosting LWS Perso.

  • data object
400

Invalid input

{
  "code": 400,
  "info": {
    "domain": "Required field"
  },
  "data": {
    "domain": "/^(?!-)([A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,15}$/"
  }
}
Response fields 3
  • code integer

    Example: 400

  • info object

    Example: {"domain":"Required field"}

  • data object

    Example: {"domain":"/^(?!-)([A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,15}$/"}

401

Unauthorized - Missing authentication headers

{
  "code": 401,
  "info": "Unauthorized access to the API. Please specify X-Auth-Pass and X-Auth-Login to proceed."
}
Response fields 2
  • code integer

    Example: 401

  • info string

    Example: Unauthorized access to the API. Please specify X-Auth-Pass and X-Auth-Login to proceed.

429

Rate limit exceeded

{
  "code": 429,
  "info": "Rate limit exceeded. Please try again later."
}
Response fields 2
  • code integer

    Example: 429

  • info string

    Example: Rate limit exceeded. Please try again later.

500

Internal Server Error

{
  "code": 500,
  "info": "Internal Server Error",
  "data": "Error message"
}
Response fields 3
  • code integer

    Example: 500

  • info string

    Example: Internal Server Error

  • data string

    Example: Error message

502

Bad Gateway

{
  "code": 502,
  "info": "Invalid response from upstream server",
  "data": []
}
Response fields 3
  • code integer

    Example: 502

  • info string

    Example: Invalid response from upstream server

  • data object
Show the code examples and the test console
POST /hosting
LWS_AUTH_LOGIN='…'LWS_AUTH_PASS='…'curl -X POST \  "https://api.lws.net/v1/hosting" \  -H "X-Auth-Login: $LWS_AUTH_LOGIN" \  -H "X-Auth-Pass: $LWS_AUTH_PASS" \  -H "Content-Type: application/json" \  -d '{"package":"LWS Perso","domain":"example.com","owner":565487,"type":"buy","period":12}'
$lwsAuthLogin = '…';$lwsAuthPass = '…';$ch = curl_init("https://api.lws.net/v1/hosting");curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_HTTPHEADER, [    "X-Auth-Login: " . $lwsAuthLogin,    "X-Auth-Pass: " . $lwsAuthPass,    "Content-Type: application/json",]);curl_setopt($ch, CURLOPT_POSTFIELDS, '{"package":"LWS Perso","domain":"example.com","owner":565487,"type":"buy","period":12}');$res = json_decode(curl_exec($ch), true);
import requestsLWS_AUTH_LOGIN = "…"LWS_AUTH_PASS = "…"res = requests.post(    "https://api.lws.net/v1/hosting",    headers={        "X-Auth-Login": LWS_AUTH_LOGIN,        "X-Auth-Pass": LWS_AUTH_PASS,    },    json={"package": "LWS Perso", "domain": "example.com", "owner": 565487, "type": "buy", "period": 12},)print(res.json())
const LWS_AUTH_LOGIN = "…";const LWS_AUTH_PASS = "…";const res = await fetch("https://api.lws.net/v1/hosting", {  method: "POST",  headers: {    "X-Auth-Login": LWS_AUTH_LOGIN,    "X-Auth-Pass": LWS_AUTH_PASS,    "Content-Type": "application/json",  },  body: JSON.stringify({"package":"LWS Perso","domain":"example.com","owner":565487,"type":"buy","period":12}),});const data = await res.json();
lwsAuthLogin := "…"lwsAuthPass := "…"body := strings.NewReader(`{"package":"LWS Perso","domain":"example.com","owner":565487,"type":"buy","period":12}`)req, _ := http.NewRequest("POST",    "https://api.lws.net/v1/hosting", body)req.Header.Set("X-Auth-Login", lwsAuthLogin)req.Header.Set("X-Auth-Pass", lwsAuthPass)req.Header.Set("Content-Type", "application/json")resp, err := http.DefaultClient.Do(req)