# Batch feedback scoring for spans

PUT http://localhost:5173/api/v1/private/spans/feedback-scores
Content-Type: application/json

Batch feedback scoring for spans

Reference: https://www.comet.com/docs/opik/reference/rest-api/spans/score-batch-of-spans

## OpenAPI Specification

```yaml
openapi: 3.1.1
info:
  title: Batch feedback scoring for spans
  version: endpoint_spans.scoreBatchOfSpans
paths:
  /v1/private/spans/feedback-scores:
    put:
      operationId: score-batch-of-spans
      summary: Batch feedback scoring for spans
      description: Batch feedback scoring for spans
      tags:
        - - subpackage_spans
      parameters: []
      responses:
        '204':
          description: No Content
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Spans_scoreBatchOfSpans_Response_204'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeedbackScoreBatch'
components:
  schemas:
    FeedbackScoreBatchItemSource:
      type: string
      enum:
        - value: ui
        - value: sdk
        - value: online_scoring
    FeedbackScoreBatchItem:
      type: object
      properties:
        project_name:
          type: string
          description: If null, the default project is used
        project_id:
          type: string
          format: uuid
        name:
          type: string
        category_name:
          type: string
        value:
          type: number
          format: double
        reason:
          type: string
        source:
          $ref: '#/components/schemas/FeedbackScoreBatchItemSource'
        author:
          type: string
        id:
          type: string
          format: uuid
      required:
        - name
        - value
        - source
        - id
    FeedbackScoreBatch:
      type: object
      properties:
        scores:
          type: array
          items:
            $ref: '#/components/schemas/FeedbackScoreBatchItem'
      required:
        - scores
    Spans_scoreBatchOfSpans_Response_204:
      type: object
      properties: {}

```

## SDK Code Examples

```python
import requests

url = "http://localhost:5173/api/v1/private/spans/feedback-scores"

payload = { "scores": [
        {
            "name": "string",
            "value": 1.1,
            "source": "ui",
            "id": "string"
        }
    ] }
headers = {"Content-Type": "application/json"}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/private/spans/feedback-scores';
const options = {
  method: 'PUT',
  headers: {'Content-Type': 'application/json'},
  body: '{"scores":[{"name":"string","value":1.1,"source":"ui","id":"string"}]}'
};

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"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "http://localhost:5173/api/v1/private/spans/feedback-scores"

	payload := strings.NewReader("{\n  \"scores\": [\n    {\n      \"name\": \"string\",\n      \"value\": 1.1,\n      \"source\": \"ui\",\n      \"id\": \"string\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Content-Type", "application/json")

	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/private/spans/feedback-scores")

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

request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"scores\": [\n    {\n      \"name\": \"string\",\n      \"value\": 1.1,\n      \"source\": \"ui\",\n      \"id\": \"string\"\n    }\n  ]\n}"

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

```java
HttpResponse<String> response = Unirest.put("http://localhost:5173/api/v1/private/spans/feedback-scores")
  .header("Content-Type", "application/json")
  .body("{\n  \"scores\": [\n    {\n      \"name\": \"string\",\n      \"value\": 1.1,\n      \"source\": \"ui\",\n      \"id\": \"string\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'http://localhost:5173/api/v1/private/spans/feedback-scores', [
  'body' => '{
  "scores": [
    {
      "name": "string",
      "value": 1.1,
      "source": "ui",
      "id": "string"
    }
  ]
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp
var client = new RestClient("http://localhost:5173/api/v1/private/spans/feedback-scores");
var request = new RestRequest(Method.PUT);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"scores\": [\n    {\n      \"name\": \"string\",\n      \"value\": 1.1,\n      \"source\": \"ui\",\n      \"id\": \"string\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = ["scores": [
    [
      "name": "string",
      "value": 1.1,
      "source": "ui",
      "id": "string"
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5173/api/v1/private/spans/feedback-scores")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

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()
```