aboutsummaryrefslogblamecommitdiffstats
path: root/paste.sr.ht/api.md
blob: 539a172d618641f111e1a6e7b2c4716017320531 (plain) (tree)
1
2
3
4
5
6
7



                                

                                                                         
                                  






                                                                                
                                                                 









                                         
                               






















                                               
                                           




                              
                            






                               
                               









                                                                           
                                                                  


            
                                          


                        
                                              
 

                              





                                            

                       
                                            
 

                              




                                                        
                                        
 
                 
 

                                   
                              
 

                 
                               


                              

                
                                           
---
title: paste.sr.ht API reference
---

The paste.sr.ht API allows you to browse and create pastes on paste.sr.ht
programmatically. This API follows the [standard sourcehut API
conventions](/api-conventions.md).

## Authentication

Authentication is done via the [meta.sr.ht OAuth
flow](https://man.sr.ht/meta.sr.ht/oauth-api.md). The following OAuth scopes are
available for paste.sr.ht:

- **pastes:read**, **pastes:write**: read & write paste resources

## Resources

### Paste resource

```json
{
  "created": "timestamp",
  "sha": "id of this paste (SHA-1 hash)",
  "user": { short-form user resource },
  "visibility": "access level",
  "files": [
    {
      "filename": "filename" or null,
      "blob_id": "id of this blob (SHA-1 hash)"
    }, ...
  ]
}
```

### Blob resource

```json
{
  "created": "timestamp",
  "sha": "id of this blob (SHA-1 hash)",
  "contents": "contents of this blob"
}
```

## Endpoints

### GET /api/pastes

List of [paste resources](#paste-resource).

**OAuth scope**: `pastes:read`

### POST /api/pastes

Create a new paste resource.

**OAuth scope**: `pastes:write`

**Request body**

```json
{
  "visibility": "access level",
  "files": [
    {
      "filename": "filename" or null, (optional)
      "contents": "contents of this file"
    }
  ]
}
```

- **contents** must be a UTF-8 encoded string; binary files are not allowed
- **visibility** must be one of "public", "private", or "unlisted"

**Response**

The new [paste resource](#paste-resource).

### GET /api/pastes/:sha

Retrieves a [paste resource](#paste-resource).

**OAuth scope**: `pastes:read`

### DELETE /api/pastes/:sha

Deletes a [paste resource](#paste-resource).

**OAuth scope**: `pastes:write`

### GET /api/blobs/:sha

Retrieves a [blob resource](#blob-resource).

**OAuth scope**: `pastes:read`

## Webhooks

### /api/pastes/...

Webhook for paste events. Includes the [standard webhook
endpoints](/api-conventions.md#webhooks)

#### paste:create

Issued when a new paste is created.

**OAuth scope**: `pastes:read`

#### paste:delete

Issued when a paste is deleted.

**OAuth scope**: `pastes:read`

**Request body**

Affected [paste resource](#paste-resource).