---
title: "Upload Google Earth Engine service account for another user (Admin only)."
method: POST
path: "/api/v1/user/{user_id}/gee-service-account"
---

# Upload Google Earth Engine service account for another user (Admin only).

`POST /api/v1/user/{user_id}/gee-service-account`

## Request

- Base URL: `https://api.trends.earth/api/v1`
- URL: `https://api.trends.earth/api/v1/api/v1/user/{user_id}/gee-service-account`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/trends/apis/trends-earth-api/docs/api/v1/user/:user_id/gee-service-account/post.ts> (a function with typed inputs; its response is checked against the schema)

**Authentication**: JWT token required
**Authorization**: ADMIN or SUPERADMIN role required
**Content-Type**: application/json

**Path Parameters**:
- `user_id`: Target user's ID (string or integer)

**Request Body Schema**:
```json
{
  "service_account_key": {
    "type": "service_account",
    "project_id": "your-gee-project",
    "private_key_id": "key-id",
    "private_key": "-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----\n",
    "client_email": "service-account@your-gee-project.iam.gserviceaccount.com",
    "client_id": "client-id",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://oauth2.googleapis.com/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/..."
  }
}
```

**Required Fields**:
- `service_account_key`: Complete service account JSON key object or JSON string

**Response Schema**:
```json
{
  "message": "GEE service account credentials saved for user user@example.com"
}
```

**Admin Use Cases**:
- Provide organizational GEE access to users
- Set up shared service account for team projects
- Replace expired or compromised credentials
- Migrate users from individual to shared credentials

**Security & Audit**:
- Admin action is logged with both admin and target user details
- Service account keys are encrypted before storage
- Replaces any existing credentials for the user

**Error Responses**:
- `400 Bad Request`: Missing service account, invalid JSON, or validation failed
- `401 Unauthorized`: JWT token required or invalid
- `403 Forbidden`: Admin access required
- `404 Not Found`: Target user not found
- `500 Internal Server Error`: Failed to save credentials

## Path parameters

- `user_id` string, required

## Request body

- object

## Response `200`

Success

- object

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `500`: Internal Server Error

---

[API](https://skmtc.dev/trends/apis/trends-earth-api.md) - [All operations](https://skmtc.dev/trends/apis/trends-earth-api/llms.txt) - [OpenAPI document](https://skmtc.dev/trends/apis/trends-earth-api/revisions/0b75d1e065e1?raw)
