---
title: "Smart API routing by Auth0 JWT Contents"
description: "Learn how to add smart routing based on token claims to your API authentication."
canonicalUrl: "https://zuplo.com/blog/2022/03/17/smart-api-routing-by-auth0-jwt-contents"
pageType: "blog"
date: "2022-03-17"
authors: "josh"
tags: "JWT API Authentication, Auth0"
image: "https://zuplo.com/og?text=Smart%20API%20routing%20by%20Auth0%20JWT%20Contents"
---
We continue with the example from this
[post](/blog/jwt-authentication-with-auth0) and add smart routing based on
claims in the token.

<YouTubeVideo videoId="XS-BMeGQPn8" />

Length: 2 minutes

Here's the function handler we create to do the smart routing

```ts
import { ZuploContext, ZuploRequest } from "@zuplo/runtime";

export default async function (request: ZuploRequest, context: ZuploContext) {
    const data = request.user.data;
    if (data["https://example.com/claim1/"] === "this-is-a-claim"){
        return fetch("https://example.com");
    }
    else {
        return fetch(`https://ecommerce-legacy.zuplo.io/objects?type=products&id=${request.params.productId});
    }
}
```