Layers
Partner APIAPI referenceGitHub

GET /v1/github/installation/install-url

Create a short-lived GitHub App install URL. Send the end-customer here.

View as Markdown
GET/v1/github/installation/install-url
Phase 1stable
Auth
Bearer
Scope
github:admin

Returns a one-time URL that, when opened in the browser, walks your user through installing the Layers GitHub App on the org or repos they choose. After install, GitHub redirects back to your returnUrl with installation_id and state query parameters — you then POST the installation_id to POST /v1/github/installation.

returnUrl must be on your key's allowedReturnDomains list. Calls with an unlisted URL fail with 403 RETURN_URL_NOT_ALLOWED so a compromised key can't redirect the user somewhere it shouldn't. URLs expire after 15 minutes.

Query
  • returnUrl
    stringrequired
    HTTPS URL on your domain that GitHub redirects to after install. Must be on the key's allowlist.
  • state
    stringoptional
    Opaque value you round-trip for CSRF. Echoed on the redirect. Layers generates one if omitted.

Example request

curl "https://api.layers.com/v1/github/installation/install-url?returnUrl=https%3A%2F%2Fapp.gicgrowth.com%2Flayers%2Fcallback" \
  -H "Authorization: Bearer lp_live_01HX9Y6K7EJ4T2_4QZpN..."
const { authUrl, state, expiresAt } = await layers.github.installUrl({
  returnUrl: "https://app.gicgrowth.com/layers/callback",
});
// Redirect the user to authUrl.
url = layers.github.install_url(
    return_url="https://app.gicgrowth.com/layers/callback",
)
# Redirect the user to url["authUrl"].

Response

200OK
{
  "authUrl": "https://github.com/apps/layers-connector/installations/new?state=lUNN5tIRm-K3...&redirect_uri=https%3A%2F%2Fapp.gicgrowth.com%2Flayers%2Fcallback",
  "installUrl": "https://github.com/apps/layers-connector/installations/new?state=lUNN5tIRm-K3...&redirect_uri=https%3A%2F%2Fapp.gicgrowth.com%2Flayers%2Fcallback",
  "state": "lUNN5tIRm-K3a8sBXvBQDxVOCgz2x9YK",
  "expiresAt": "2026-04-18T19:29:09.000Z"
}

installUrl is an alias for authUrl — both are the same value, kept for clients that prefer the shorter name. Either is safe to redirect to.

Errors

StatusCodeWhen
422VALIDATIONreturnUrl missing or not HTTPS.
401UNAUTHENTICATEDMissing or invalid key.
403FORBIDDEN_SCOPEKey lacks github:admin.
403RETURN_URL_NOT_ALLOWEDreturnUrl is not on the key's allowedReturnDomains list. Update via ladmin or your organization dashboard.
429RATE_LIMITEDWrite budget exhausted.

See also

On this page