# Change a site’s title, who can see it, or its invites

```http
PATCH /api/sites/{id}
```

## 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

- **title** `string`: At most 120 characters
- **visibility** `"public" | "link" | "invite"`
- **invites** `array<string>`: At most 2000 items
- **newKey** `boolean`
- **newsletter** `boolean`

## 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

Other answers:

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

## Example request

````tabs
tab: cURL
```bash
curl -X PATCH 'https://your-hatch-server/api/sites/{id}' \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "string",
  "visibility": "public",
  "invites": [
    "string"
  ],
  "newKey": true,
  "newsletter": true
}'
```

tab: JavaScript
```js
const res = await fetch("https://your-hatch-server/api/sites/{id}", {
  method: "PATCH",
  headers: {
    Authorization: "Bearer <token>",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "title": "string",
    "visibility": "public",
    "invites": [
      "string"
    ],
    "newKey": true,
    "newsletter": true
  }),
})
const data = await res.json()
```

tab: Python
```python
import requests

res = requests.request("PATCH", "https://your-hatch-server/api/sites/{id}", headers={"Authorization": "Bearer <token>", "Content-Type": "application/json"}, json={
    "title": "string",
    "visibility": "public",
    "invites": [
        "string",
    ],
    "newKey": True,
    "newsletter": True,
})
data = res.json()
```

tab: Go
```go
package main

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

func main() {
	body := strings.NewReader(`{
	  "title": "string",
	  "visibility": "public",
	  "invites": [
	    "string"
	  ],
	  "newKey": true,
	  "newsletter": true
	}`)
	req, err := http.NewRequest("PATCH", "https://your-hatch-server/api/sites/{id}", body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer <token>")
	req.Header.Set("Content-Type", "application/json")
	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"
require "json"

uri = URI('https://your-hatch-server/api/sites/{id}')
req = Net::HTTP::Patch.new(uri)
req['Authorization'] = 'Bearer <token>'
req['Content-Type'] = 'application/json'
req.body = JSON.generate({
  'title' => 'string',
  'visibility' => 'public',
  'invites' => [
    'string'
  ],
  'newKey' => true,
  'newsletter' => true
})

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}');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer <token>',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{
      "title": "string",
      "visibility": "public",
      "invites": [
        "string"
      ],
      "newKey": true,
      "newsletter": true
    }',
]);

$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}"))
    .header("Authorization", "Bearer <token>")
    .header("Content-Type", "application/json")
    .method("PATCH", HttpRequest.BodyPublishers.ofString("{\"title\":\"string\",\"visibility\":\"public\",\"invites\":[\"string\"],\"newKey\":true,\"newsletter\":true}"))
    .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"
    }
  }
}
```

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