> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Start Slack OAuth Organization Flow

> Start the Slack OAuth flow for a specific Organization

export const member = "Represents an individual end user's account within a given Organization, uniquely identified within that Organization by their email address.";

export const organization = "Represents an instance or tenant in your application, typically mapping to each of your top-level customers.";

export const oauth = "OAuth, otherwise known as Social Login or Social SSO, is an easy way for end users to sign-up and login to your application through their authenticated identity on another application, such as Google or Microsoft.";

A client-side endpoint (can only be queried from the browser) that starts the Slack <Tooltip tip={oauth}>OAuth</Tooltip> flow. This endpoint generates a Slack OAuth URL with all required fields and redirects the user to that URL. The user authenticates with Slack before getting redirected back to Stytch. After verifying the request, Stytch redirects the user back to the `login_redirect_url` or `signup_redirect_url` provided.

One of `organization_id` or `slug` is required to specify which organization the user is trying to access. If the organization that the user is trying to access is not yet known, use the [Slack OAuth Discovery endpoint](/api-reference/b2b/api/oauth/discovery/start-slack) instead.

#### Scopes

By default our Slack OAuth integration requests the `open_id`, `email`, and `profile` scopes. You may add any additional Slack API scopes (see [here](https://api.slack.com/scopes) for a complete list) as a space separated list in the `custom_scopes` query parameter.

#### Authenticating the OAuth Token

## Once the user successfully authenticates with Slack, they'll be redirected to the redirect URL that you provided at the start of the OAuth flow with a Stytch OAuth token. Collect the token from the URL query parameters, then call [Authenticate OAuth Token](/api-reference/b2b/api/oauth/organization/authenticate) to complete authentication. The OAuth 2.0 Access Token and ID token will also be made available via the [Get Slack Access Token endpoint](/api-reference/b2b/api/oauth/token/slack).

### Path Parameters

<ParamField path="public_token" type="string" required>
  The public token found in your [Stytch Dashboard](https://stytch.com/dashboard). Since this endpoint must be called client-side, the public token authenticates the request instead of the project ID and secret.
</ParamField>

<ParamField body="organization_id" type="string">
  The unique ID of the <Tooltip tip={organization}>Organization</Tooltip> to authenticate the <Tooltip tip={member}>Member</Tooltip> into.
</ParamField>

<ParamField body="slug" type="string">
  The unique URL slug of the <Tooltip tip={organization}>Organization</Tooltip> to authenticate the <Tooltip tip={member}>Member</Tooltip> into. The slug only accepts alphanumeric characters and the following reserved characters: `-` `.` `_` `~`. Must be between 2 and 128 characters in length. Wherever an `organization_id` is expected in a path or request parameter, you may instead use the `organization_slug` as a convenience.
</ParamField>

<ParamField body="login_redirect_url" type="string">
  The URL Stytch redirects to after the OAuth flow is completed for a Member that already exists. This URL should be a route in your application which will call [OAuth Authenticate](/api-reference/b2b/api/oauth/organization/authenticate) and finish the login.

  The URL must be configured as a Login URL in the [Stytch Dashboard](https://stytch.com/dashboard/redirect-urls). If the field is not specified, the default Login URL will be used.
</ParamField>

<ParamField body="signup_redirect_url" type="string">
  The URL Stytch redirects to after the OAuth flow is completed for a Member that does not yet exist. This URL should be a route in your application which will call [OAuth Authenticate](/api-reference/b2b/api/oauth/organization/authenticate) and finish the login.

  The URL must be configured as a Login URL in the [Stytch Dashboard](https://stytch.com/dashboard/redirect-urls). If the field is not specified, the default Login URL will be used.
</ParamField>

<ParamField body="custom_scopes" type="string">
  A space-separated list of custom scopes that you'd like to include. Note that this list must be URL encoded (e.g. the spaces must be expressed as %20).
</ParamField>

<ParamField body="provider_[parameter_name]" type="string">
  Any parameters that should be forwarded to the OAuth provider can be passed as query parameters with the `provider_` prefix. For example, some OAuth providers support a `login_hint` parameter that allows you to pre-populate the OAuth login flow with a suggested email address. To specify the `login_hint` parameter in your OAuth request, include `provider_login_hint=exampleHint` as a query parameter.

  We recommend consulting each OAuth provider's documentation for a list of supported parameters.
</ParamField>

<ParamField body="pkce_code_challenge" type="string">
  A base64url encoded SHA256 hash of a one time secret used to validate that the request starts and ends on the same device.
</ParamField>

### Response

<ResponseField name="redirect_url" type="string">
  The url to redirect to. This should be done automatically by the browser.
</ResponseField>

<ResponseField name="status_code" type="number">
  The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values
  equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
</ResponseField>

<ResponseField name="request_id" type="string">
  Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we
  may ask for this value to help identify a specific API call when helping you debug an issue.
</ResponseField>

<Panel>
  <RequestExample>
    ```js theme={null}
    // Client-side in the user's browser
    const response = await fetch('https://test.stytch.com/v1/b2b/public/oauth/slack/start?public_token=public-token-test-be835f9a-ac37-44cf-817d-f58ac2b3ae3d&organization_id=organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931', {
      method: 'GET',
    });
    ```
  </RequestExample>

  <ResponseExample>
    ```json 307 theme={null}
    {
      "status_code": 307,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "redirect_url": "https://slack.com/o/oauth2/v2/authorize?access_type=offline&client_id=example-client-id&redirect_uri=https%3A%2F%2Fstytch.com%2Fv1%2Foauth%2Foauth-callback-test-d868b16b-3ecd-49ac-7fc6-e3d1051c5d65&response_type=code&access_type=offline&state=example-state&user_scope=users%3Aread+users%3Aread.email",
    }
    ```

    ```json 400 theme={null}
    {
      "status_code": 400,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "duplicate_email",
      "error_message": "A user with the specified email already exists for this project.",
      "error_url": "https://stytch.com/docs/api/errors/400"
    }
    ```

    ```json 401 theme={null}
    {
      "status_code": 401,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "unauthorized_credentials",
      "error_message": "Unauthorized credentials.",
      "error_url": "https://stytch.com/docs/api/errors/401"
    }
    ```

    ```json 429 theme={null}
    {
      "status_code": 429,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "too_many_requests",
      "error_message": "Too many requests have been made.",
      "error_url": "https://stytch.com/docs/api/errors/429"
    }
    ```

    ```json 500 theme={null}
    {
      "status_code": 500,
      "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
      "error_type": "internal_server_error",
      "error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
      "error_url": "https://stytch.com/docs/api/errors/500"
    }
    ```
  </ResponseExample>
</Panel>
