# Pub/Sub API reference

Source: `@socra/pubsub-api@0.0.2` (PubsubContract).

Durable project-scoped publish and subscribe delivery.

## API surface

Base URL: `https://pubsub.socra.cloud`

## Topics

A project-owned feed to which messages are published.

### Resource schema

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `status` "active" | "deleted", required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "deleted"
      ]
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "status",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Create topic

`POST /v1/projects/{project_id}/topics`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Request body

- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `retention_seconds` integer (default: 86400; min: 600; max: 604800), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "retention_seconds": {
      "default": 86400,
      "type": "integer",
      "minimum": 600,
      "maximum": 604800
    }
  },
  "required": [
    "name"
  ]
}
```

#### Response

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `status` "active" | "deleted", required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "deleted"
      ]
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "status",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### List topics

`GET /v1/projects/{project_id}/topics`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Query parameters

- `limit` integer (min: 1; max: 100), optional
- `after` string, optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    }
  }
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `project_id` custom, required
  - `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
  - `resource_name` string, required
  - `status` "active" | "deleted", required
  - `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
  - `created_at` custom, required
  - `updated_at` custom, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "project_id": {},
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
          },
          "resource_name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "deleted"
            ]
          },
          "retention_seconds": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "created_at": {},
          "updated_at": {}
        },
        "required": [
          "id",
          "project_id",
          "name",
          "resource_name",
          "status",
          "retention_seconds",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Get topic

`GET /v1/projects/{project_id}/topics/{topic}`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `topic` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `status` "active" | "deleted", required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "deleted"
      ]
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "status",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Update topic

`PATCH /v1/projects/{project_id}/topics/{topic}`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `topic` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Request body

- `retention_seconds` integer (min: 600; max: 604800), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "retention_seconds": {
      "type": "integer",
      "minimum": 600,
      "maximum": 604800
    }
  }
}
```

#### Response

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `status` "active" | "deleted", required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "deleted"
      ]
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "status",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Delete topic

`DELETE /v1/projects/{project_id}/topics/{topic}`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `topic` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Response

No response body.

## Topic bindings

A project permission to publish to or subscribe to a topic.

### Resource schema

- `id` custom, required
- `topic` string, required
- `project_id` custom, required
- `role` "publisher" | "subscriber", required
- `created_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "topic": {
      "type": "string"
    },
    "project_id": {},
    "role": {
      "type": "string",
      "enum": [
        "publisher",
        "subscriber"
      ]
    },
    "created_at": {}
  },
  "required": [
    "id",
    "topic",
    "project_id",
    "role",
    "created_at"
  ],
  "additionalProperties": false
}
```

### Create topic binding

`POST /v1/projects/{project_id}/topics/{topic}/bindings`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `topic` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Request body

- `project_id` custom, required
- `role` "publisher" | "subscriber", required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "project_id": {},
    "role": {
      "type": "string",
      "enum": [
        "publisher",
        "subscriber"
      ]
    }
  },
  "required": [
    "project_id",
    "role"
  ]
}
```

#### Response

- `id` custom, required
- `topic` string, required
- `project_id` custom, required
- `role` "publisher" | "subscriber", required
- `created_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "topic": {
      "type": "string"
    },
    "project_id": {},
    "role": {
      "type": "string",
      "enum": [
        "publisher",
        "subscriber"
      ]
    },
    "created_at": {}
  },
  "required": [
    "id",
    "topic",
    "project_id",
    "role",
    "created_at"
  ],
  "additionalProperties": false
}
```

### List topic bindings

`GET /v1/projects/{project_id}/topics/{topic}/bindings`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `topic` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Query parameters

- `limit` integer (min: 1; max: 100), optional
- `after` string, optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    }
  }
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `topic` string, required
  - `project_id` custom, required
  - `role` "publisher" | "subscriber", required
  - `created_at` custom, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "topic": {
            "type": "string"
          },
          "project_id": {},
          "role": {
            "type": "string",
            "enum": [
              "publisher",
              "subscriber"
            ]
          },
          "created_at": {}
        },
        "required": [
          "id",
          "topic",
          "project_id",
          "role",
          "created_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Delete topic binding

`DELETE /v1/projects/{project_id}/topics/{topic}/bindings/{binding_id}`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `topic` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```

- `binding_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

No response body.

## Subscriptions

An independently acknowledged delivery stream from one topic.

### Resource schema

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `topic` string (pattern: ^projects\/proj_[0-9a-hjkmnp-tv-z]{26}\/topics\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `status` "active" | "paused" | "deleted", required
- `ack_deadline_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "topic": {
      "type": "string",
      "pattern": "^projects\\/proj_[0-9a-hjkmnp-tv-z]{26}\\/topics\\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "deleted"
      ]
    },
    "ack_deadline_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "topic",
    "status",
    "ack_deadline_seconds",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Create subscription

`POST /v1/projects/{project_id}/subscriptions`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Request body

- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `topic` string (pattern: ^projects\/proj_[0-9a-hjkmnp-tv-z]{26}\/topics\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `ack_deadline_seconds` integer (default: 60; min: 10; max: 600), optional
- `retention_seconds` integer (default: 86400; min: 600; max: 604800), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "topic": {
      "type": "string",
      "pattern": "^projects\\/proj_[0-9a-hjkmnp-tv-z]{26}\\/topics\\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "ack_deadline_seconds": {
      "default": 60,
      "type": "integer",
      "minimum": 10,
      "maximum": 600
    },
    "retention_seconds": {
      "default": 86400,
      "type": "integer",
      "minimum": 600,
      "maximum": 604800
    }
  },
  "required": [
    "name",
    "topic"
  ]
}
```

#### Response

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `topic` string (pattern: ^projects\/proj_[0-9a-hjkmnp-tv-z]{26}\/topics\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `status` "active" | "paused" | "deleted", required
- `ack_deadline_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "topic": {
      "type": "string",
      "pattern": "^projects\\/proj_[0-9a-hjkmnp-tv-z]{26}\\/topics\\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "deleted"
      ]
    },
    "ack_deadline_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "topic",
    "status",
    "ack_deadline_seconds",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### List subscriptions

`GET /v1/projects/{project_id}/subscriptions`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Query parameters

- `limit` integer (min: 1; max: 100), optional
- `after` string, optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    }
  }
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `project_id` custom, required
  - `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
  - `resource_name` string, required
  - `topic` string (pattern: ^projects\/proj_[0-9a-hjkmnp-tv-z]{26}\/topics\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
  - `status` "active" | "paused" | "deleted", required
  - `ack_deadline_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
  - `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
  - `created_at` custom, required
  - `updated_at` custom, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "project_id": {},
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
          },
          "resource_name": {
            "type": "string"
          },
          "topic": {
            "type": "string",
            "pattern": "^projects\\/proj_[0-9a-hjkmnp-tv-z]{26}\\/topics\\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "paused",
              "deleted"
            ]
          },
          "ack_deadline_seconds": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "retention_seconds": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "created_at": {},
          "updated_at": {}
        },
        "required": [
          "id",
          "project_id",
          "name",
          "resource_name",
          "topic",
          "status",
          "ack_deadline_seconds",
          "retention_seconds",
          "created_at",
          "updated_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Get subscription

`GET /v1/projects/{project_id}/subscriptions/{subscription}`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `subscription` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `topic` string (pattern: ^projects\/proj_[0-9a-hjkmnp-tv-z]{26}\/topics\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `status` "active" | "paused" | "deleted", required
- `ack_deadline_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "topic": {
      "type": "string",
      "pattern": "^projects\\/proj_[0-9a-hjkmnp-tv-z]{26}\\/topics\\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "deleted"
      ]
    },
    "ack_deadline_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "topic",
    "status",
    "ack_deadline_seconds",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Update subscription

`PATCH /v1/projects/{project_id}/subscriptions/{subscription}`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `subscription` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Request body

- `status` "active" | "paused", optional
- `ack_deadline_seconds` integer (min: 10; max: 600), optional
- `retention_seconds` integer (min: 600; max: 604800), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused"
      ]
    },
    "ack_deadline_seconds": {
      "type": "integer",
      "minimum": 10,
      "maximum": 600
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": 600,
      "maximum": 604800
    }
  }
}
```

#### Response

- `id` custom, required
- `project_id` custom, required
- `name` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `resource_name` string, required
- `topic` string (pattern: ^projects\/proj_[0-9a-hjkmnp-tv-z]{26}\/topics\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required
- `status` "active" | "paused" | "deleted", required
- `ack_deadline_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `retention_seconds` integer (min: -9007199254740991; max: 9007199254740991), required
- `created_at` custom, required
- `updated_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 128,
      "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "resource_name": {
      "type": "string"
    },
    "topic": {
      "type": "string",
      "pattern": "^projects\\/proj_[0-9a-hjkmnp-tv-z]{26}\\/topics\\/[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "active",
        "paused",
        "deleted"
      ]
    },
    "ack_deadline_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "retention_seconds": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    },
    "created_at": {},
    "updated_at": {}
  },
  "required": [
    "id",
    "project_id",
    "name",
    "resource_name",
    "topic",
    "status",
    "ack_deadline_seconds",
    "retention_seconds",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false
}
```

### Delete subscription

`DELETE /v1/projects/{project_id}/subscriptions/{subscription}`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `subscription` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Response

No response body.

## Publishers

Message publication operations.

### Publish messages

`POST /v1/projects/{project_id}/topics/{topic}/publish`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `topic` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Request body

- `publisher_project_id` custom, optional
- `messages` object[] (min items: 1; max items: 100), required
  - `data` string (max length: 10000000), required
  - `attributes` object (default: {}), optional
  - `ordering_key` string (max length: 1024), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "publisher_project_id": {},
    "messages": {
      "minItems": 1,
      "maxItems": 100,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "maxLength": 10000000
          },
          "attributes": {
            "default": {},
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "string"
            }
          },
          "ordering_key": {
            "type": "string",
            "maxLength": 1024
          }
        },
        "required": [
          "data"
        ]
      }
    }
  },
  "required": [
    "messages"
  ]
}
```

#### Response

- `message_ids` custom[], required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "message_ids": {
      "type": "array",
      "items": {}
    }
  },
  "required": [
    "message_ids"
  ],
  "additionalProperties": false
}
```

## Subscribers

Subscription delivery operations.

### Pull messages

`POST /v1/projects/{project_id}/subscriptions/{subscription}/pull`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `subscription` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Request body

- `max_messages` integer (default: 10; min: 1; max: 100), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "max_messages": {
      "default": 10,
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    }
  }
}
```

#### Response

- `received_messages` object[], required
  - `ack_token` string, required
  - `delivery_attempt` integer (min: 1; max: 9007199254740991), required
  - `message` object, required
    - `data` string (max length: 10000000), required
    - `attributes` object (default: {}), required
    - `ordering_key` string (max length: 1024), optional
    - `id` custom, required
    - `published_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "received_messages": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "ack_token": {
            "type": "string"
          },
          "delivery_attempt": {
            "type": "integer",
            "minimum": 1,
            "maximum": 9007199254740991
          },
          "message": {
            "type": "object",
            "properties": {
              "data": {
                "type": "string",
                "maxLength": 10000000
              },
              "attributes": {
                "default": {},
                "type": "object",
                "propertyNames": {
                  "type": "string"
                },
                "additionalProperties": {
                  "type": "string"
                }
              },
              "ordering_key": {
                "type": "string",
                "maxLength": 1024
              },
              "id": {},
              "published_at": {}
            },
            "required": [
              "data",
              "attributes",
              "id",
              "published_at"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "ack_token",
          "delivery_attempt",
          "message"
        ],
        "additionalProperties": false
      }
    }
  },
  "required": [
    "received_messages"
  ],
  "additionalProperties": false
}
```

### Acknowledge messages

`POST /v1/projects/{project_id}/subscriptions/{subscription}/acknowledge`

#### Path parameters

- `project_id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```

- `subscription` string (min length: 1; max length: 128; pattern: ^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$), required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "string",
  "minLength": 1,
  "maxLength": 128,
  "pattern": "^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$"
}
```


#### Request body

- `ack_tokens` string[] (min items: 1; max items: 1000), required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "ack_tokens": {
      "minItems": 1,
      "maxItems": 1000,
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "ack_tokens"
  ]
}
```

#### Response

- `acknowledged_count` integer (min: -9007199254740991; max: 9007199254740991), required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "acknowledged_count": {
      "type": "integer",
      "minimum": -9007199254740991,
      "maximum": 9007199254740991
    }
  },
  "required": [
    "acknowledged_count"
  ],
  "additionalProperties": false
}
```

---

Company: Socra — Multiply Your Judgment
Canonical URL: https://cloud.socra.com/docs/pubsub/reference/api
