OCS User Sync API

Introduction

This endpoint triggers user-sync for a specific user.

  • Path: ocs/v2.php/cloud/user-sync/<userid>

  • Method: POST

Requirements

This endpoint can only be executed by a user with admin privileges. We suggest creating a technical user who is in the admin group to run this command with.

Request Parameters

Attribute Type Description

userid

string

The id of the user to trigger a sync for.

Returns

The request returns the following status codes.

Status Code When…​

HTTP 200 OK

The user sync was executed.

HTTP 404 Not Found

The supplied user id is unknown.

HTTP 409 Conflict

Multiple users have been found for the given user id.

Example Responses

<?xml version="1.0"?>
<ocs>
    <meta>
        <status>ok</status>
        <statuscode>200</statuscode>
        <message/>
        <totalitems></totalitems>
        <itemsperpage></itemsperpage>
    </meta>
    <data/>
</ocs>

Code Example

  • Curl

  • PHP

#!/usr/bin/env bash

##
## Variable Declaration
##
USERNAME=username
PASSWORD=password
API_PATH="ocs/v2.php/cloud/user-sync/<userid>"
SERVER_URI="https://owncloud.install.com/owncloud"

curl '$SERVER_URI/$API_PATH/' \
  -H 'Content-Type: application/xml; charset=UTF-8' \
  -X POST \
  --user "${USERNAME}:${PASSWORD}"
<?php

use GuzzleHttp\Client;

require_once ('vendor/autoload.php');

// Configure the basic client
$basePath = 'https://owncloud.install.com/owncloud';
$requestPath = 'ocs/v2.php/cloud/user-sync/admin';
$username = 'username';
$password = 'password';

$client = new Client([
    'base_uri' => $basePath,
]);

try {
    $response = $client->post($requestPath, [
        'auth' => [$username, $password],
        'debug' => true,
    ]);
    print $response->getBody()->getContents();
} catch (\GuzzleHttp\Exception\ClientException $e) {
    print $e->getMessage();
}