OCS-API for adding an user to a team

Hello, I am asking here if anyone knows what parameters I need for the request to add users to a team in NextCloud. I dont see any documentation on this anywhere and I didn’t find anything else that would help me finding this out on my own.

I think the endpoint for the OCS is

{base_url}/ocs/v2.php/apps/circles/circles/{circle_id}/members

I tried as parameters:

data = {"id": f"{username}", "type": 1}

But I keep getting an Internal Server Error here… can anyone maybe help me out here ?

What needs to be changed for my current OCS request ?

So when looking at the request that is done by web, it looks like this:

ocs/v2.php/apps/circles/circles/{circles_id}/members/multi

{
    "members": [
        {
            "id": "bob",
            "type": 1
        }
    ]
}

Seems this is a different endpoint. Not really sure if we have that in documentation somwhere

Hello, and thanks for your quick response.

I assume this endpoint is for adding more than one user at a time to a team, I’m not really sure though, since I cannot test that; the request also didn’t work with this endpoint.

My request:

data = { "members": [{"id": "jflemming", "type": 1}]}
    hdrs2 = {'OCS-APIRequest': 'true', 'Accept': 'application/json', 'Content-Type': 'application/json'}

    r = requests.post(f"{base_url}/ocs/v2.php/apps/circles/circles/{circle_id}/members/multi", auth=auth, headers=hdrs2, data=data)

naturally my auth should be correct (worked with other OCS-Requests); and the circle ID I am using is also the long string that is also used with the request done by web.

I still do get an Internal Server Error as a response.

Really, I’m at the end of my wits here. If you do have documentation on this, then it truly is hidden well.

In that case you should see an exception in your nextcloud.log - anything useful there about your request?

Okay, so I did look in the logs and at least now there’s something to go off on:

{"reqId":"0XvEpT6a9CMeUIS9J6iD","level":3,"time":"2025-10-
02T09:51:07+00:00","remoteAddr":"172.19.0.1","user":"admin","app":"no app in 
context","method":"POST","url":"/ocs/v2.php/apps/circles/circles/xP3d1JhxvZFDaLtosM
hcAedIqEVkFpa/members/multi?format=json","message": ...

"Previous":
{"Exception":"TypeError","Message":"OCA\\Circles\\Controller\\LocalController::memb
ersAdd(): Argument #2 ($members) must be of type array, null given, called in 
/var/www/html/lib/private/AppFramework/Http/Dispatcher.php on line 
204","Code":0,"Trace":
[{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":204,"f
unction":"membersAdd","class":"OCA\\Circles\\Controller\\LocalController","type":"-
>","args":["xP3d1JhWvZFDaLtosMhcAedIqEVkFpa",null]},
{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",

So it seems that for some reason, the API endpoint does not pick up the second argument with the member information, and instead interprets it as null. Which I do find curious, since I do obviously provide that information via the data field.