# Add a member to a team — API reference

> Adds a Company member to a team and returns no response body.

Source: https://upfour.io/docs/api/teams/add-a-member-to-a-team

[Developers](https://upfour.io/docs/api.md)/[Teams](https://upfour.io/docs/api/teams.md)

Adds a Company member to a team and returns no response body.

POST https://app.upfour.io/v1/teams/{teamID}/members

scope member.write stable [Idempotency-Key supported](https://upfour.io/docs/api/idempotency.md) returns 201

## Parameters

| Field | Type | Description |
| --- | --- | --- |
| `teamID` required | uuid | path parameter |

## Body

`application/json` required 2 fields

user_iduuid (required)

A user that is a member of the company.

All other fields1 fields

rolestring

Omitted or any other value adds the user as member. Adding someone who is already in the team changes nothing.

adminmemberviewer

## Returns

A successful request returns `201` with no response body.

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 404 | [not_found](https://upfour.io/docs/api/errors#code-not_found) | The requested resource does not exist or is outside the caller's scope. |
| 403 | [permission_denied](https://upfour.io/docs/api/errors#code-permission_denied) | The credentials do not permit this action. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousList team members](https://upfour.io/docs/api/teams/list-team-members.md) [NextGet a team member by email](https://upfour.io/docs/api/teams/get-a-team-member-by-email.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/teams/00000000-0000-4000-8000-000000000001/members" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "member",
    "user_id": "00000000-0000-4000-8000-000000000002"
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/teams/00000000-0000-4000-8000-000000000001/members", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    role: "member",
    user_id: "00000000-0000-4000-8000-000000000002",
  }),
});
console.log(res.status);
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/teams/00000000-0000-4000-8000-000000000001/members",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "role": "member",
        "user_id": "00000000-0000-4000-8000-000000000002",
    },
)
print(res.status_code)
```

### Go

```go
package main

import (
	"fmt"
	"net/http"
	"os"
	"strings"
)

func main() {
	payload := strings.NewReader(`{
  "role": "member",
  "user_id": "00000000-0000-4000-8000-000000000002"
}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/teams/00000000-0000-4000-8000-000000000001/members", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	fmt.Println(res.StatusCode)
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "role": "member",
  "user_id": "00000000-0000-4000-8000-000000000002"
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/teams/00000000-0000-4000-8000-000000000001/members");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), "\n";
curl_close($ch);
```

## Response

### 201

```
Done. The response has no body.
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 403

```json
{
  "error": {
    "code": "permission_denied",
    "message": "The credentials do not permit this action.",
    "request_id": "req_…"
  }
}
```

### 404

```json
{
  "error": {
    "code": "not_found",
    "message": "The requested resource does not exist or is outside the caller's scope.",
    "request_id": "req_…"
  }
}
```
