> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://www.comet.com/docs/opik/llms.txt.

# Run a project's nightly update now

POST http://localhost:5173/api/v1/internal/topics/projects/{projectId}/night

Queues the project's nightly update for the night date (UTC; default today, at most tomorrow, at least the vectors backfill window ago) and returns its run id; any pod runs it. Its window ends at the night's start. The run's outcome is on the project's topic_projects row while it is the project's latest run, and in the run's logs. The workspace is opted in to topics at stage nightly or later, the project has a list whose window ends before the night, its window holds topics.run.minVectors vectors, and it has no run in flight. topics.runs.maxInFlight and the night's budget do not apply, and the project's night fields are not written.

Reference: https://www.comet.com/docs/opik/reference/rest-api/topics/run-project-topics-night

## Servers

- `http://localhost:5173/api` (Local server, default)
- `https://www.comet.com/opik/api` (Opik Cloud)

## Request

### Path parameters

- `projectId` (string, required)

### Query parameters

- `workspace_id` (string, required)
- `night` (string, optional)

## Response

### 202

The run is queued

## Errors

### 400 Bad Request Error

The night is not a date, is after tomorrow, or is longer ago than the vectors backfill window

- `any`

### 409 Conflict Error

The workspace is not opted in at stage nightly or later, or topics are off, the night would skip the project (reason no_list, deleted, already_saved or small, named in the message), or a run is in flight

- `any`

### 503 Service Unavailable Error

The run could not be started; nothing is queued, try again

- `any`

## Examples

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "http://localhost:5173/api/v1/internal/topics/projects/projectId/night"

querystring = {"workspace_id":"workspace_id"}

response = requests.post(url, params=querystring)

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/internal/topics/projects/projectId/night?workspace_id=workspace_id';
const options = {method: 'POST'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "http://localhost:5173/api/v1/internal/topics/projects/projectId/night?workspace_id=workspace_id"

	req, _ := http.NewRequest("POST", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("http://localhost:5173/api/v1/internal/topics/projects/projectId/night?workspace_id=workspace_id")

http = Net::HTTP.new(url.host, url.port)

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("http://localhost:5173/api/v1/internal/topics/projects/projectId/night?workspace_id=workspace_id")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'http://localhost:5173/api/v1/internal/topics/projects/projectId/night?workspace_id=workspace_id');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("http://localhost:5173/api/v1/internal/topics/projects/projectId/night?workspace_id=workspace_id");
var request = new RestRequest(Method.POST);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5173/api/v1/internal/topics/projects/projectId/night?workspace_id=workspace_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```