# API Error: Resource already exists (ALREADY_EXISTS / resource_already_exists / 409)

**Code:** `ALREADY_EXISTS` · **Category:** API · **Seen on:** REST API

The create request was refused because an object with the same unique identity — name, email, external ID — already exists.

## Meaning

Most APIs enforce uniqueness on some field. gRPC and Google Cloud APIs return status ALREADY_EXISTS, others resource_already_exists, duplicate_resource or a plain 409 Conflict with “already exists”.

It very often happens on retries: the first create actually succeeded but the response was lost (timeout), so the client tried again.

## Common causes

- An object with the same unique key really exists
- A timed-out create succeeded and the retry duplicates it
- Two workers created the same object concurrently
- Soft-deleted object still reserves the name

## Quick fix

1. Look up the existing object and use it (get-or-create)
2. Use an idempotency key so retries return the original result
3. Choose a different unique value if it’s a genuine clash

## Detailed fix by platform

### Node.js

1. `try { await api.create({ name }); } catch (e) { if (e.status === 409
2. e.code === 'ALREADY_EXISTS') return api.getByName(name); throw e; }`

### gcloud

1. `gcloud pubsub topics describe my-topic
2. gcloud pubsub topics create my-topic   # create only if missing`

## How to diagnose

1. **Search** — Does an object with that key exist already?
2. **Retries** — Did an earlier attempt time out?
3. **Concurrency** — Multiple creators?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/api/resource-already-exists)
