# Insert badge data (bulk) POST https://api.trebellar.app/api/v2/badge Content-Type: application/json Reference: https://docs.trebellar.app/api-reference/api-resources/badge/bulk-insert-badge ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Insert badge data (bulk) version: endpoint_badge.bulkInsertBadge paths: /api/v2/badge: post: operationId: bulk-insert-badge summary: Insert badge data (bulk) tags: - - subpackage_badge parameters: - name: X-Trebellar-Api-Key in: header required: true schema: type: string responses: '200': description: Successful operation content: application/json: schema: $ref: '#/components/schemas/badge_bulkInsertBadge_Response_200' '400': description: Bad request content: {} '422': description: Unprocessable Content content: {} requestBody: content: application/json: schema: type: object properties: readings: type: array items: $ref: '#/components/schemas/BadgeReading' required: - readings components: schemas: GenericId: type: string BadgeReadingReadAt: oneOf: - type: number format: double - type: string BadgeReadingReading: type: object properties: userId: type: string peopleGroupId: type: - string - 'null' peopleType: type: - string - 'null' visitType: type: - string - 'null' seated: type: - boolean - 'null' BadgeReading: type: object properties: id: $ref: '#/components/schemas/GenericId' readAt: $ref: '#/components/schemas/BadgeReadingReadAt' reading: $ref: '#/components/schemas/BadgeReadingReading' required: - id - readAt badge_bulkInsertBadge_Response_200: type: object properties: insertedEntries: type: number format: double required: - insertedEntries ``` ## SDK Code Examples ```typescript import { TrebellarApiClient } from "@trebellar/api-sdk"; async function main() { const client = new TrebellarApiClient({ environment: "https://api.trebellar.app", }); await client.badge.bulkInsertBadge({ readings: [ { id: "eid:sfo-001", readAt: 1.1, }, ], }); } main(); ``` ```python from trebellar import TrebellarApi client = TrebellarApi( base_url="https://api.trebellar.app", api_key= ) client.badge.bulk_insert_badge( readings=[ { "id": "eid:sfo-001", "read_at": 1.1 } ] ) ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.trebellar.app/api/v2/badge" payload := strings.NewReader("{\n \"readings\": [\n {\n \"id\": \"eid:sfo-001\",\n \"readAt\": 1.1\n }\n ]\n}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Trebellar-Api-Key", "") 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("https://api.trebellar.app/api/v2/badge") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-Trebellar-Api-Key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"readings\": [\n {\n \"id\": \"eid:sfo-001\",\n \"readAt\": 1.1\n }\n ]\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api.trebellar.app/api/v2/badge") .header("X-Trebellar-Api-Key", "") .header("Content-Type", "application/json") .body("{\n \"readings\": [\n {\n \"id\": \"eid:sfo-001\",\n \"readAt\": 1.1\n }\n ]\n}") .asString(); ``` ```php request('POST', 'https://api.trebellar.app/api/v2/badge', [ 'body' => '{ "readings": [ { "id": "eid:sfo-001", "readAt": 1.1 } ] }', 'headers' => [ 'Content-Type' => 'application/json', 'X-Trebellar-Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.trebellar.app/api/v2/badge"); var request = new RestRequest(Method.POST); request.AddHeader("X-Trebellar-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"readings\": [\n {\n \"id\": \"eid:sfo-001\",\n \"readAt\": 1.1\n }\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-Trebellar-Api-Key": "", "Content-Type": "application/json" ] let parameters = ["readings": [ [ "id": "eid:sfo-001", "readAt": 1.1 ] ]] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.trebellar.app/api/v2/badge")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" 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() ```