{
  "openapi": "3.1.0",
  "info": {
    "title": "Link in Seconds API",
    "version": "1.0.0",
    "description": "Upload a file and get a public link. Uploads go straight to storage in three steps: create an upload, PUT the bytes to the signed URL, complete it. The account's plan limits, file-type checks and moderation apply to every upload."
  },
  "servers": [
    {
      "url": "https://linkinseconds.com/api/v1"
    }
  ],
  "externalDocs": {
    "url": "https://linkinseconds.com/docs/developers"
  },
  "security": [
    {
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from /dashboard/api-keys (starts with lis_)."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          },
          "code": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      },
      "Link": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "review": {
            "type": "boolean",
            "description": "Held for moderation review; goes live once cleared."
          },
          "processing": {
            "type": "boolean",
            "description": "A video still being scanned."
          }
        },
        "required": [
          "slug",
          "title",
          "url"
        ]
      },
      "AnalyticsReport": {
        "type": "object",
        "description": "The same report the dashboard renders. All dates are UTC; range.to is exclusive. Bots and link previews are excluded and counted in totals.botsExcluded. Atypical sessions (bots, email scanners, link previews) are counted in totals.atypical, flagged in recent[].atypical and kept out of every average. Engagement fields come from the viewer's session and are 0 for opens recorded before engagement tracking existed.",
        "properties": {
          "range": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string",
                "enum": [
                  "7d",
                  "14d",
                  "30d",
                  "90d",
                  "all"
                ]
              },
              "from": {
                "type": "string",
                "format": "date-time"
              },
              "to": {
                "type": "string",
                "format": "date-time"
              },
              "days": {
                "type": "integer"
              },
              "label": {
                "type": "string"
              }
            }
          },
          "totals": {
            "type": "object",
            "properties": {
              "views": {
                "type": "integer"
              },
              "uniques": {
                "type": "integer"
              },
              "sessions": {
                "type": "integer",
                "description": "Opens with engagement data"
              },
              "avgEngagedMs": {
                "type": "integer"
              },
              "medianEngagedMs": {
                "type": "integer"
              },
              "totalEngagedMs": {
                "type": "integer"
              },
              "completionPct": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Pages reached, media played or scroll depth, by file kind"
              },
              "downloads": {
                "type": "integer",
                "description": "All-time, not windowed"
              },
              "qrScans": {
                "type": "integer"
              },
              "returningPct": {
                "type": "number"
              },
              "bouncePct": {
                "type": "number",
                "description": "Opens under 5 engaged seconds"
              },
              "botsExcluded": {
                "type": "integer"
              },
              "atypical": {
                "type": "integer",
                "description": "Sessions by a bot, email scanner or link preview: counted and listed, not in sessions or any average"
              }
            }
          },
          "previous": {
            "type": "object",
            "description": "The same width of time before the range"
          },
          "deltas": {
            "type": "object",
            "properties": {
              "views": {
                "type": "object",
                "properties": {
                  "pct": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Signed percent change vs the previous period; null when the previous period was 0"
                  },
                  "dir": {
                    "type": "string",
                    "enum": [
                      "up",
                      "down",
                      "flat"
                    ]
                  }
                },
                "required": [
                  "pct",
                  "dir"
                ]
              },
              "uniques": {
                "type": "object",
                "properties": {
                  "pct": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Signed percent change vs the previous period; null when the previous period was 0"
                  },
                  "dir": {
                    "type": "string",
                    "enum": [
                      "up",
                      "down",
                      "flat"
                    ]
                  }
                },
                "required": [
                  "pct",
                  "dir"
                ]
              },
              "avgEngagedMs": {
                "type": "object",
                "properties": {
                  "pct": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Signed percent change vs the previous period; null when the previous period was 0"
                  },
                  "dir": {
                    "type": "string",
                    "enum": [
                      "up",
                      "down",
                      "flat"
                    ]
                  }
                },
                "required": [
                  "pct",
                  "dir"
                ]
              },
              "downloads": {
                "type": "object",
                "properties": {
                  "pct": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Signed percent change vs the previous period; null when the previous period was 0"
                  },
                  "dir": {
                    "type": "string",
                    "enum": [
                      "up",
                      "down",
                      "flat"
                    ]
                  }
                },
                "required": [
                  "pct",
                  "dir"
                ]
              }
            }
          },
          "granularity": {
            "type": "string",
            "enum": [
              "day",
              "week"
            ]
          },
          "series": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "label": {
                  "type": "string"
                },
                "views": {
                  "type": "integer"
                },
                "uniques": {
                  "type": "integer"
                },
                "avgEngagedS": {
                  "type": "integer"
                }
              }
            }
          },
          "breakdowns": {
            "type": "object",
            "properties": {
              "countries": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              },
              "cities": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              },
              "referrers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              },
              "sources": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              },
              "devices": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              },
              "browsers": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              },
              "os": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              },
              "screens": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "key": {
                      "type": "string"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "pct": {
                      "type": "number",
                      "description": "Share of the total, 0 to 100"
                    }
                  },
                  "required": [
                    "key",
                    "count",
                    "pct"
                  ]
                }
              }
            }
          },
          "timing": {
            "type": "object",
            "properties": {
              "byHour": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "minItems": 24,
                "maxItems": 24
              },
              "byWeekday": {
                "type": "array",
                "items": {
                  "type": "integer"
                },
                "minItems": 7,
                "maxItems": 7,
                "description": "Sunday first"
              },
              "heat": {
                "type": "array",
                "items": {
                  "type": "array",
                  "items": {
                    "type": "integer"
                  }
                },
                "description": "[weekday][hour]"
              },
              "peakHour": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "peakWeekday": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          },
          "content": {
            "type": "object",
            "description": "kind: pages (PDF), media (video, audio), scroll (pages, images, text) or none. pages carries dropoff {afterPage, lostPct} and media.dropoff {beforePct, lostPct}, null until at least 3 sessions and a loss of 10 points"
          },
          "insights": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "label": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "detail": {
                  "type": "string"
                },
                "tone": {
                  "type": "string",
                  "enum": [
                    "good",
                    "neutral",
                    "warn"
                  ]
                }
              }
            }
          },
          "recent": {
            "type": "array",
            "description": "The 25 most recent opens with engagement data",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "LinkSummary": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "views": {
            "type": "integer"
          },
          "uniques": {
            "type": "integer"
          },
          "avgEngagedMs": {
            "type": "integer"
          },
          "completionPct": {
            "type": [
              "number",
              "null"
            ]
          },
          "downloads": {
            "type": "integer"
          },
          "spark": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "description": "Daily views, oldest first, up to 30"
          }
        }
      }
    }
  },
  "paths": {
    "/uploads": {
      "post": {
        "operationId": "createUpload",
        "summary": "Start an upload and get a one-time signed PUT URL (valid 10 minutes)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "File name with extension"
                  },
                  "type": {
                    "type": "string",
                    "description": "MIME type; send the same value as Content-Type on the PUT"
                  },
                  "size": {
                    "type": "integer",
                    "description": "Exact size in bytes"
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Optional; retry-safe key, reuse it on /uploads/complete"
                  }
                },
                "required": [
                  "name",
                  "type",
                  "size"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload URL ready (or the existing link when the idempotency key was already used)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "path": {
                      "type": "string"
                    },
                    "signedUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "existing": {
                      "$ref": "#/components/schemas/Link"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or file type",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Plan limit reached or account banned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too many uploads this hour",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/uploads/complete": {
      "post": {
        "operationId": "completeUpload",
        "summary": "Verify, scan and publish an uploaded file",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "path": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "type": {
                    "type": "string"
                  },
                  "linkName": {
                    "type": "string",
                    "description": "Optional link title"
                  },
                  "idempotencyKey": {
                    "type": "string",
                    "format": "uuid"
                  }
                },
                "required": [
                  "path",
                  "name",
                  "type"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The new link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Link"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input or file type",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Plan limit reached or account banned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Too many uploads this hour",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/links": {
      "get": {
        "operationId": "listLinks",
        "summary": "List the account's links, newest first",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Links",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "links": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "slug": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "url": {
                            "type": "string",
                            "format": "uri"
                          },
                          "kind": {
                            "type": "string"
                          },
                          "size_bytes": {
                            "type": "integer"
                          },
                          "created_at": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "live",
                              "review",
                              "processing",
                              "disabled"
                            ]
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/links/{slug}/analytics": {
      "get": {
        "operationId": "getLinkAnalytics",
        "summary": "Analytics for one link over a UTC window (Pro)",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "range",
            "in": "query",
            "description": "UTC window. Default 30d.",
            "schema": {
              "type": "string",
              "enum": [
                "7d",
                "14d",
                "30d",
                "90d",
                "all"
              ],
              "default": "30d"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The link and its report",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "type": "object",
                      "properties": {
                        "link": {
                          "type": "object",
                          "properties": {
                            "slug": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "url": {
                              "type": "string",
                              "format": "uri"
                            },
                            "kind": {
                              "type": "string"
                            }
                          }
                        }
                      }
                    },
                    {
                      "$ref": "#/components/schemas/AnalyticsReport"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "code bad_range: range is not one of 7d, 14d, 30d, 90d, all",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "code pro_required (Free plan) or banned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "code not_found: no such link on this account",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/analytics": {
      "get": {
        "operationId": "getAccountAnalytics",
        "summary": "Analytics across every link on the account over a UTC window (Pro)",
        "parameters": [
          {
            "name": "range",
            "in": "query",
            "description": "UTC window. Default 30d.",
            "schema": {
              "type": "string",
              "enum": [
                "7d",
                "14d",
                "30d",
                "90d",
                "all"
              ],
              "default": "30d"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The account report with its top links and file-kind mix",
            "content": {
              "application/json": {
                "schema": {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/AnalyticsReport"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "top_links": {
                          "type": "array",
                          "maxItems": 25,
                          "items": {
                            "$ref": "#/components/schemas/LinkSummary"
                          }
                        },
                        "mix": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "key": {
                                "type": "string"
                              },
                              "count": {
                                "type": "integer"
                              },
                              "pct": {
                                "type": "number",
                                "description": "Share of the total, 0 to 100"
                              }
                            },
                            "required": [
                              "key",
                              "count",
                              "pct"
                            ]
                          }
                        },
                        "all_time": {
                          "type": "object",
                          "properties": {
                            "views": {
                              "type": "integer"
                            },
                            "downloads": {
                              "type": "integer"
                            },
                            "links": {
                              "type": "integer"
                            }
                          }
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "code bad_range",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "code pro_required (Free plan) or banned",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/status": {
      "get": {
        "operationId": "status",
        "summary": "Health check",
        "security": [],
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      }
    }
  }
}