---
title: "Upsert a User"
method: POST
path: "/v2/users"
tags: ["V2"]
---

# Upsert a User

`POST /v2/users`

Endpoint facilitating the programatic upsertion of a user.
Users must be upserted 1 at a time.
Events created for this user are for historical tracking purposes. Any event tied to a user through this endpoint will not trigger a study through Sprig's SDK.
Attributes and attribute values can be created and tied to a user through this endpoint.

## Headers

- `Authorization` string, required

## Request body

- object
  - `attributes` object — Key value pairs of attributes
    - `attributeName` string — Attribute name and value. Attributes limited to total of 100 values
  - `emailAddress` string — Valid Email to track visitor by
  - `events` object[]
    - `event` string — Name of event already being tracked in Sprig
    - `timestamp` integer — Unix timestamp in milliseconds
  - `userId` string, required — Existing or desired id for visitor

## Response `202`

Accepted

## Other responses

- `400` — Bad Request
- `422` — Unprocessable Entity
- `500` — Something went wrong on Sprig's side. These are very rare :)

---

[API](https://skmtc.dev/sprig/apis/sprig-api.md) · [All operations](https://skmtc.dev/sprig/apis/sprig-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/sprig/sprig-api/revisions/e415b6f55281/schema)
