Identity Management

POST /user/{userId}

Requires authentication with server access token.

Update existing user objects. Password, emails and phone numbers cannot be updated through the API, the user maintains full control over those through the SPiD profile UI.

See also

Help us improve

Did you spot an error? Or maybe you just have a suggestion for how we can improve? Leave us a comment.

Request

POST /api/2/user/{userId}

userId

required path parameter

The user's uuid or userId (not to be mistaken with the deprecated id).

displayName

optional

New preferred display name

name

optional

JSON object containing givenName and familyName

birthday

optional

New date of birth, YYYY-MM-DD

addresses

optional

A JSON string. A map of addresses, with the address type as keys and the address objects/maps as values. See the address type for appropriate types

gender

optional

New gender. Legal values and a localized description can be fetched from /api/2/describe/User?property=gender.

photo

optional

URL to a profile photo

preferredUsername

optional

New preferred user name

url

optional

New external URL related to the user

utcOffset

optional

New timezone, given as UTC offset (number of hours), e.g. "+02:00"

Example request

cURL
Minimal example
curl https://login.schibsted.com/api/2/user/42 \
   -X POST \
   -d "oauth_token=[access token]"
With all parameters
curl https://login.schibsted.com/api/2/user/42 \
   -X POST \
   -d "oauth_token=[access token]" \
   -d "displayName=John" \
   -d "name=John Doe" \
   -d "birthday=1977-01-31" \
   -d "addresses={"home":{"country":"Norway","streetNumber":"1","longitude":"","floor":"","locality":"","formatted":"STREET 1, 0123 OSLO, NORGE","streetEntrance":"","apartment":"","postalCode":"0123","latitude":"","type":"home","region":"","streetAddress":"STREET"}}" \
   -d "gender=undisclosed" \
   -d "photo=http://gravatar.com/xyz" \
   -d "preferredUsername=johnd" \
   -d "url=http://example.com" \
   -d "utcOffset=+02:00"
Java
Minimal example
SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
    POST(token, "/user/42").
    getResponseBody();
With all parameters
Map<String, String> params = new HashMap<>() {{
    put("displayName", "John");,
    put("name", "John Doe");,
    put("birthday", "1977-01-31");,
    put("addresses", "{"home":{"country":"Norway","streetNumber":"1","longitude":"","floor":"","locality":"","formatted":"STREET 1, 0123 OSLO, NORGE","streetEntrance":"","apartment":"","postalCode":"0123","latitude":"","type":"home","region":"","streetAddress":"STREET"}}");,
    put("gender", "undisclosed");,
    put("photo", "http://gravatar.com/xyz");,
    put("preferredUsername", "johnd");,
    put("url", "http://example.com");,
    put("utcOffset", "+02:00");
}};

SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
    POST(token, "/user/42", params).
    getResponseBody();

This example is an excerpt, see a full example

PHP
Minimal example
<?php
$client->auth();
echo var_dump($client->api("/user/42", "POST"));
With all parameters
<?php
$params = array(
    "displayName" => "John",
    "name" => "John Doe",
    "birthday" => "1977-01-31",
    "addresses" => "{"home":{"country":"Norway","streetNumber":"1","longitude":"","floor":"","locality":"","formatted":"STREET 1, 0123 OSLO, NORGE","streetEntrance":"","apartment":"","postalCode":"0123","latitude":"","type":"home","region":"","streetAddress":"STREET"}}",
    "gender" => "undisclosed",
    "photo" => "http://gravatar.com/xyz",
    "preferredUsername" => "johnd",
    "url" => "http://example.com",
    "utcOffset" => "+02:00"
);

$client->auth();
echo var_dump($client->api("/user/42", "POST", $params));

This example is an excerpt, see a full example

Clojure
Minimal example
(ns example
  (:require [spid-client-clojure.core :as spid]))

(let [client (spid/create-client "[client-id]" "[secret]")
      token (spid/create-server-token client)]
  (spid/POST client token "/user/42"))
With all parameters
(ns example
  (:require [spid-client-clojure.core :as spid]))

(let [client (spid/create-client "[client-id]" "[secret]")
      token (spid/create-server-token client)]
  (spid/POST client token "/user/42" {"displayName" "John"
                                      "name" "John Doe"
                                      "birthday" "1977-01-31"
                                      "addresses" "{"home":{"country":"Norway","streetNumber":"1","longitude":"","floor":"","locality":"","formatted":"STREET 1, 0123 OSLO, NORGE","streetEntrance":"","apartment":"","postalCode":"0123","latitude":"","type":"home","region":"","streetAddress":"STREET"}}"
                                      "gender" "undisclosed"
                                      "photo" "http://gravatar.com/xyz"
                                      "preferredUsername" "johnd"
                                      "url" "http://example.com"
                                      "utcOffset" "+02:00"}))

Response

This endpoint supports the JSON, JSON-P, and response formats.

Success: 200 OK

Returns the updated user object.

User

The user object is based on the portable contacts specification. It is extended with some custom fields. userId is an integer and represents the unique user ID, while id is a legacy uuid and should be ignored in new integrations. The uuid is also a user identifier, which is is globally unique and should therefore be the preferred identifier for a user. The email and phoneNumber fields will always contain the primary used for both if available. The corresponding *Verified fields are the date of the last time those were verified.

When requesting a user that is not connected to the authorized client, only public profile data will be available:

  • id
  • userId
  • uuid
  • status
  • displayName
  • name
  • gender
  • preferredUsername
  • utcOffset
  • published
  • updated
  • lastLoggedIn
  • locale
  • tracking

id

string

Legacy uuid. Don't use. Portable contacts

userId

integer (as string)

Unique user ID. Custom extension.

uuid

string

Unique user UUID. Custom extension. Should be preferred as the user identifier.

name

Name

A JSON string. See the name type for details

displayName

string

Name suitable for displaying to end-users.

published

date-time

The date this user was first added. Can return false if the user account was deleted.

updated

date-time

The most recent date the details of this user were updated

status

User status

email

string

Primary email

emailVerified

string

Date when the email was last verified.

emails

list of Email addresses

All user's registered email addresses.

phoneNumber

string

Primary phone number

phoneNumberVerified

string

Date when the phone number was last verified.

phoneNumbers

list of Phone numbers

All user's registered phone numbers.

verified

string

Date when user last verified data (email, phone number). Returns false if user wasn't verified.

url

string

photo

string

URL to a photo of the user (GIF/JPG/PNG)

preferredUsername

string

gender

string

One of undisclosed, female, male, other, withheld. Default is undisclosed. Portable contacts

birthday

date

Date of birth in YYYY-MM-DD format. Year will be 0000 if not provided. Defaults to 0000-00-00. Portable contacts

locale

string

The user's preferred locale. Locales follow ISO Language and country codes respectively, joined by an underscore.

utcOffset

string

The user's timezone, given as offset from UTC.

lastLoggedIn

datetime

Returns false if the user has not been logged in before.

lastAuthenticated

datetime

The last time the user authenticated with their password. Returns false if the user has not been authenticated before.

imported

datetime

migrated

datetime

addresses

collection of Addresses, as an object with type for property names, and Addresses for values

If user has no addresses returns empty array.

accounts

list of Third-party accounts

Third-party accounts and other client services

merchants

array

List of SPiD merchants the user is connected to

currentLocation

list of Addresses

If user has no current location returns empty array.

tracking

boolean

If true, the user has behavioral tracking enabled (pilot feature, may not remain as-is)

The check mark indicates that the field always contains a valid non-empty value.

Failure cases

Some HTTP response codes are used for multiple error situations. There is no consistent way to tell these apart, but the error object will contain a textual explanation of the reason for the error. For explanation on OAuth related failures and errors see OAuth authentication failures.

  • 401 Unauthorized You don't have administration rights for this client.
  • 401 Unauthorized Your client doesn't have administration rights for this client.
  • 403 Forbidden Client is not authorized to access this API endpoint. Contact SPiD to request access.
  • 403 Forbidden Requesting IP is not whitelisted
  • 403 Forbidden Client is not authorized to access this user
  • 403 Forbidden Token is not authorized to access this user
  • 403 Forbidden Client or merchant is not authorized to access this user
  • 403 Forbidden Access token rejected
  • 404 Not Found Unknown client ID
  • 404 Not Found Client ID mismatch. The client making the request is no the owner of this resource, and does not have administrative privileges for it.
  • 404 Not Found Requested user was not found
  • 404 Not Found User was not found
  • 420 Request Ratelimit exceeded

Sample response

JSON
{
  "status": 0,
  "merchants": [
    47000
  ],
  "gender": "undisclosed",
  "userId": "679518",
  "name": {
    "familyName": "Doe",
    "givenName": "John",
    "formatted": "John Doe"
  },
  "accounts": {
    "52f8e3d9efd04bb749000000": {
      "id": "52f8e3d9efd04bb749000000",
      "accountName": "Kodemaker",
      "domain": "www.kodemaker.no"
    }
  },
  "locale": "nb_NO",
  "photo": "https://secure.gravatar.com/avatar/6a6c19fea4a3676970167ce51f39e6ee?s\u003d200",
  "phoneNumberVerified": false,
  "phoneNumber": "",
  "displayName": "John Doe",
  "utcOffset": "+02:00",
  "emails": [
    {
      "value": "user@domain1.tld",
      "type": "other"
    }
  ],
  "published": "2014-04-15 19:43:29",
  "hashType": "bcrypt",
  "url": "",
  "updated": "2014-04-28 16:33:00",
  "email": "user@domain.tld",
  "lastAuthenticated": false,
  "emailVerified": false,
  "preferredUsername": "JohnDoe",
  "currentLocation": [],
  "addresses": {
    "home": {
      "country": "Norway",
      "streetNumber": "1",
      "longitude": "",
      "floor": "",
      "locality": "",
      "formatted": "STREET 1, 0123 OSLO, NORGE",
      "streetEntrance": "",
      "apartment": "",
      "postalCode": "0123",
      "latitude": "",
      "type": "home",
      "region": "",
      "streetAddress": "STREET"
    }
  },
  "verified": "2014-04-15 19:43:29",
  "id": "534d6fc1efd04b7c3f000000",
  "phoneNumbers": [],
  "birthday": "0000-00-00",
  "lastLoggedIn": false,
  "passwordChanged": false
}
JSON-P
callback({
  "status": 0,
  "merchants": [
    47000
  ],
  "gender": "undisclosed",
  "userId": "679518",
  "name": {
    "familyName": "Doe",
    "givenName": "John",
    "formatted": "John Doe"
  },
  "accounts": {
    "52f8e3d9efd04bb749000000": {
      "id": "52f8e3d9efd04bb749000000",
      "accountName": "Kodemaker",
      "domain": "www.kodemaker.no"
    }
  },
  "locale": "nb_NO",
  "photo": "https://secure.gravatar.com/avatar/6a6c19fea4a3676970167ce51f39e6ee?s\u003d200",
  "phoneNumberVerified": false,
  "phoneNumber": "",
  "displayName": "John Doe",
  "utcOffset": "+02:00",
  "emails": [
    {
      "value": "user@domain1.tld",
      "type": "other"
    }
  ],
  "published": "2014-04-15 19:43:29",
  "hashType": "bcrypt",
  "url": "",
  "updated": "2014-04-28 16:33:00",
  "email": "user@domain.tld",
  "lastAuthenticated": false,
  "emailVerified": false,
  "preferredUsername": "JohnDoe",
  "currentLocation": [],
  "addresses": {
    "home": {
      "country": "Norway",
      "streetNumber": "1",
      "longitude": "",
      "floor": "",
      "locality": "",
      "formatted": "STREET 1, 0123 OSLO, NORGE",
      "streetEntrance": "",
      "apartment": "",
      "postalCode": "0123",
      "latitude": "",
      "type": "home",
      "region": "",
      "streetAddress": "STREET"
    }
  },
  "verified": "2014-04-15 19:43:29",
  "id": "534d6fc1efd04b7c3f000000",
  "phoneNumbers": [],
  "birthday": "0000-00-00",
  "lastLoggedIn": false,
  "passwordChanged": false
});

Comments/feedback

Do you have questions, or just want to contribute some newly gained insight? Want to share an example? Please leave a comment. SPiD reads and responds to every question. Additionally, your experience can help others using SPiD, and it can help us continuously improve our documentation.