API Documentation
Documents
POST document

POST /v1/document

Create a document.

Request Body (possible options)

{
  "content": "hello world!",
  "settings": {
    "language": "plaintext",
    "expiration": null,
    "image_embed": false,
    "instant_delete": false,
    "encrypted": false,
    "password": "",
    "public": false,
    "long_urls": false,
    "short_urls": false,
    "public": false,
    "create_gist": false,
    "editors": ["username"]
  }
}
ℹ️

All fields except content are optional

⚠️

You must be authenticated AND confirmed to use any settings.

Encryption

If you are using the API and not the frontend and you want to encrypt your document, we will encrypt it on the API instead of on the client. You can pass in your own password however if its not provided, we will generate a cryptographically secure password for you and send it in the object.

Example

Minimal Example:

fetch("https://api.impb.in/v1/document", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    content: "hello world!",
  }),
})
  .then((res) => res.json())
  .then(console.log)
  .catch((err) => console.error(err));

Options:

fetch("https://api.impb.in/v1/document", {
  method: "POST",
  headers: {
    Authorization: "imperial_123456789",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    content: "hello world!",
    settings: {
      language: "plaintext",
      expiration: null,
      image_embed: false,
      instant_delete: false,
      encrypted: false,
      password: "",
      public: false,
      long_urls: false,
      short_urls: false,
      public: false,
      create_gist: false,
      editors: ["username"],
    },
  }),
})
  .then((res) => res.json())
  .then(console.log)
  .catch((err) => console.error(err));

Responses

200 OK

{
  "success": true,
  "data": {
    "id": "MO0lJElX",
    "content": "hello world!",
    "creator": null,
    "gist_url": null,
    "views": 0,
    "timestamps": {
      "creation": "2023-04-15T20:40:45.045Z",
      "expiration": "2023-04-22T20:40:45.045Z"
    },
    "links": {
      "formatted": "https://impb.in/MO0lJElX",
      "raw": "https://impb.in/r/MO0lJElX"
    },
    "settings": {
      "language": "plaintext",
      "image_embed": false,
      "instant_delete": false,
      "encrypted": false,
      "public": false,
      "editors": []
    }
  }
}

404 Not Found

{
  "success": false,
  "error": {
    "message": "Document not found"
  }
}

5xx Internal Server Error

{
  "success": false,
  "error": {
    "message": "Internal server error"
  }
}