# Publish a built site

The body is a zip of the built site. Answers the site and how many files changed.

```http
PUT /api/sites/{id}/deploy
```

## Authorization

- **session**: `Authorization: Bearer <token>`. The session token from signing in (or the session cookie in a browser on the same origin).

## Path parameters

- **id** `string` (required)

## Request body `application/octet-stream`

`string (binary)`

## Response

**200**: It worked

- **site** `Site` (required)
  - **id** `string` (required): At most 300 characters
  - **slug** `string` (required): At most 300 characters
  - **title** `string` (required): At most 300 characters
  - **visibility** `"public" | "link" | "invite"` (required)
  - **invites** `array<string>` (required)
  - **key** `string` (required): The secret in a link-only site’s address. At most 100 characters
  - **bytes** `number` (required)
  - **files** `number` (required)
  - **updatedAt** `number | null` (required)
  - **newsletter** `boolean` (required): The site takes email sign-ups
  - **takenDown** `object | null` (required)
    - One of: **Option 1**
      - **reason** `string` (required): At most 100000 characters
      - **at** `number` (required)
  - **url** `string` (required): At most 2000 characters
  - **domain** `DomainState | null`
    - One of: **DomainState**
      - **domain** `string` (required): At most 300 characters
      - **verified** `boolean` (required)
      - **proof** `boolean | null` (required)
      - **pointing** `boolean | null` (required)
      - **checkedAt** `number | null` (required)
      - **records** `array<object>` (required)
      - **addresses** `array<string>` (required)
  - **webhook** `object | null`
    - One of: **Option 1**
      - **url** `string` (required): At most 500 characters
- **files** `number` (required)

Other answers:

- **4XX**: Refused, with a message to show the person

## Example request

````tabs
tab: cURL
```bash
curl -X PUT 'https://your-hatch-server/api/sites/{id}/deploy' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/octet-stream'
```

tab: JavaScript
```js
const res = await fetch("https://your-hatch-server/api/sites/{id}/deploy", {
  method: "PUT",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/octet-stream",
  },
})
const data = await res.json()
```

tab: Python
```python
import requests

res = requests.request("PUT", "https://your-hatch-server/api/sites/{id}/deploy", headers={"Authorization": "Bearer <token>", "Content-Type": "application/octet-stream"})
data = res.json()
```

tab: Go
```go
package main

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

func main() {
	req, err := http.NewRequest("PUT", "https://your-hatch-server/api/sites/{id}/deploy", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer <token>")
	req.Header.Set("Content-Type", "application/octet-stream")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	data, _ := io.ReadAll(res.Body)
	fmt.Println(string(data))
}
```

tab: Ruby
```ruby
require "net/http"

uri = URI('https://your-hatch-server/api/sites/{id}/deploy')
req = Net::HTTP::Put.new(uri)
req['Authorization'] = 'Bearer <token>'
req['Content-Type'] = 'application/octet-stream'

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(req)
end
puts res.body
```

tab: PHP
```php
<?php

$ch = curl_init('https://your-hatch-server/api/sites/{id}/deploy');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PUT',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <token>',
        'Content-Type: application/octet-stream',
    ],
]);

$response = curl_exec($ch);
echo $response;
```

tab: Java
```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://your-hatch-server/api/sites/{id}/deploy"))
    .header("Authorization", "Bearer <token>")
    .header("Content-Type", "application/octet-stream")
    .method("PUT", HttpRequest.BodyPublishers.noBody())
    .build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```
````

## Example response

````tabs
tab: 200
```json
{
  "site": {
    "id": "string",
    "slug": "string",
    "title": "string",
    "visibility": "public",
    "invites": [
      "string"
    ],
    "key": "string",
    "bytes": 0,
    "files": 0,
    "updatedAt": 0,
    "newsletter": true,
    "takenDown": {
      "reason": "string",
      "at": 0
    },
    "url": "string",
    "domain": {
      "domain": "string",
      "verified": true,
      "proof": true,
      "pointing": true,
      "checkedAt": 0,
      "records": [
        {
          "type": "CNAME",
          "name": null,
          "value": null
        }
      ],
      "addresses": [
        "string"
      ]
    },
    "webhook": {
      "url": "string"
    }
  },
  "files": 0
}
```

tab: 4XX
```json
{
  "message": "string",
  "code": "string",
  "retryable": true,
  "requestId": "string"
}
```
````
