# Batch Add People to Groups PATCH https://api.trebellar.app/api/v2/people/batch/groups/add Content-Type: application/json Add people as members to multiple groups Reference: https://docs.trebellar.app/api-reference/api-resources/people/add-people-group-members-batch ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Batch Add People to Groups version: endpoint_people.addPeopleGroupMembersBatch paths: /api/v2/people/batch/groups/add: patch: operationId: add-people-group-members-batch summary: Batch Add People to Groups description: Add people as members to multiple groups tags: - - subpackage_people parameters: - name: X-Trebellar-Api-Key in: header required: true schema: type: string responses: '200': description: People added to groups successfully content: application/json: schema: $ref: '#/components/schemas/AddPeopleGroupMembersBatchResponse' '400': description: Bad Request Error content: {} '500': description: Internal Server Error content: {} requestBody: content: application/json: schema: $ref: '#/components/schemas/AddPeopleGroupMembersBatchRequest' components: schemas: AddPeopleGroupMembersBatchRequest: type: object properties: peopleIds: type: array items: type: string groupIds: type: array items: type: string required: - peopleIds - groupIds AddPeopleGroupMembersBatchResponseData: type: object properties: {} AddPeopleGroupMembersBatchResponse: type: object properties: data: $ref: '#/components/schemas/AddPeopleGroupMembersBatchResponseData' required: - data ``` ## SDK Code Examples ```typescript import { TrebellarApiClient } from "@trebellar/api-sdk"; async function main() { const client = new TrebellarApiClient({ environment: "https://api.trebellar.app", }); await client.people.addPeopleGroupMembersBatch({ peopleIds: [ "string", ], groupIds: [ "string", ], }); } main(); ``` ```python from trebellar import TrebellarApi client = TrebellarApi( base_url="https://api.trebellar.app", api_key= ) client.people.add_people_group_members_batch( people_ids=[ "string" ], group_ids=[ "string" ] ) ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.trebellar.app/api/v2/people/batch/groups/add" payload := strings.NewReader("{\n \"peopleIds\": [\n \"string\"\n ],\n \"groupIds\": [\n \"string\"\n ]\n}") req, _ := http.NewRequest("PATCH", 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/people/batch/groups/add") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Patch.new(url) request["X-Trebellar-Api-Key"] = '' request["Content-Type"] = 'application/json' request.body = "{\n \"peopleIds\": [\n \"string\"\n ],\n \"groupIds\": [\n \"string\"\n ]\n}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.patch("https://api.trebellar.app/api/v2/people/batch/groups/add") .header("X-Trebellar-Api-Key", "") .header("Content-Type", "application/json") .body("{\n \"peopleIds\": [\n \"string\"\n ],\n \"groupIds\": [\n \"string\"\n ]\n}") .asString(); ``` ```php request('PATCH', 'https://api.trebellar.app/api/v2/people/batch/groups/add', [ 'body' => '{ "peopleIds": [ "string" ], "groupIds": [ "string" ] }', 'headers' => [ 'Content-Type' => 'application/json', 'X-Trebellar-Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp var client = new RestClient("https://api.trebellar.app/api/v2/people/batch/groups/add"); var request = new RestRequest(Method.PATCH); request.AddHeader("X-Trebellar-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"peopleIds\": [\n \"string\"\n ],\n \"groupIds\": [\n \"string\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "X-Trebellar-Api-Key": "", "Content-Type": "application/json" ] let parameters = [ "peopleIds": ["string"], "groupIds": ["string"] ] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api.trebellar.app/api/v2/people/batch/groups/add")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "PATCH" 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() ```