# Create a new link Source: https://docs.codeqr.io/api-reference/endpoint/create-a-link post /links Create a new link for the authenticated workspace. # Create a new QR Code Source: https://docs.codeqr.io/api-reference/endpoint/create-a-qrcode post /qrcodes Create a new QR Code for the authenticated workspace. # Create a new tag Source: https://docs.codeqr.io/api-reference/endpoint/create-a-tag post /tags Create a new tag for the authenticated project. # Delete a link Source: https://docs.codeqr.io/api-reference/endpoint/delete-a-link delete /links/{linkId} Delete a link for the authenticated workspace. # Delete a QR Code Source: https://docs.codeqr.io/api-reference/endpoint/delete-a-qrcode delete /qrcodes/{qrcodeId} Delete a QR Code for the authenticated workspace. # Retrieve a link Source: https://docs.codeqr.io/api-reference/endpoint/retrieve-a-link get /links/info Retrieve the info for a link. You can retrieve a link by providing one of the following as a query parameter: * `domain` and `key`. * `linkId`. * `externalId`. # Retrieve a list of links Source: https://docs.codeqr.io/api-reference/endpoint/retrieve-a-list-of-links get /links Retrieve a paginated list of links for the authenticated workspace. # Retrieve a list of QR Codes Source: https://docs.codeqr.io/api-reference/endpoint/retrieve-a-list-of-qrcode get /qrcodes Retrieve a paginated list of QR Codes for the authenticated workspace. # Retrieve a list of tags Source: https://docs.codeqr.io/api-reference/endpoint/retrieve-a-list-of-tags get /tags Retrieve a list of tags for the authenticated workspace. # Retrieve a QR Code Source: https://docs.codeqr.io/api-reference/endpoint/retrieve-a-qrcode get /qrcodes/info Retrieve the info for a QR Code. You can retrieve a QR Code by providing one of the following as a query parameter: * `domain` and `key`. * `qrcodeId`. * `externalId`. # Retrieve links count Source: https://docs.codeqr.io/api-reference/endpoint/retrieve-number-of-links get /links/count Retrieve the number of links for the authenticated project. The provided query parameters allow filtering the returned links. # Retrieve QR Codes count Source: https://docs.codeqr.io/api-reference/endpoint/retrieve-number-of-qrcode get /qrcodes/count Retrieve the number of QR Codes for the authenticated project. The provided query parameters allow filtering the returned links. # Update a link Source: https://docs.codeqr.io/api-reference/endpoint/update-a-link put /links/{linkId} Update a link for the authenticated workspace. If there's no change, returns it as it is. # Update a QR Code Source: https://docs.codeqr.io/api-reference/endpoint/update-a-qrcode put /qrcodes/{qrcodeId} Update a QR Code for the authenticated workspace. If there's no change, returns it as it is. # Update a tag Source: https://docs.codeqr.io/api-reference/endpoint/update-a-tag put /tags/{id} Update a tag in the workspace. # Upsert a link Source: https://docs.codeqr.io/api-reference/endpoint/upsert-a-link patch /links/update # Upsert a qrcode Source: https://docs.codeqr.io/api-reference/endpoint/upsert-a-qrcode put /qrcodes/upsert # Introduction Source: https://docs.codeqr.io/api-reference/introduction Fundamental concepts of CodeQR's API. > [!NOTE] > > CodeQR's API is now generally available. [Read the > announcement](https://codeqr.io/blog/announcing-codeqr-api). ## Base URL CodeQR's API is built on REST principles and is served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported. The Base URL for all API endpoints is: ```bash Terminal theme={null} https://api.codeqr.io ``` ## Authentication Authentication to CodeQR's API is performed via the Authorization header with a Bearer token. To authenticate, you need to include the Authorization header with the word `Bearer` followed by your API key in your requests like so: ```bash Terminal theme={null} Authorization: Bearer codeqr_xxxxxx ``` Here are examples of how to authenticate with CodeQR's API in different programming languages: ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/links \ --header 'Authorization: Bearer codeqr_xxxxxx' ``` Learn more about [how to get your API key](/api-reference/tokens). ## Native SDKs CodeQR offers native SDKs in some of the most popular programming languages: * [TypeScript SDK](/sdks/typescript) You can find the full list of SDKs [here](/sdks/overview). ## Error Handling CodeQR API returns machine readable error codes, human readable error messages and a link to the docs for more information. Here is how an error response looks like: ```json theme={null} { "error": { "code": "not_found", "message": "The requested resource was not found.", "doc_url": "https://docs.codeqr.io/api-reference/errors#not-found" } } ``` Here is a list of all error codes CodeQR API returns: > [accordion] bad\_request > > * **Status:** 400 > * **Problem:** The request is malformed, either missing required fields, using wrong datatypes, or being syntactically incorrect. > * **Solution:** Check the request and make sure it is properly formatted. > [accordion] unauthorized > > * **Status:** 401 > * **Problem:** The request has not been applied because it lacks valid authentication credentials for the target resource. > * **Solution:** Make sure you are using the correct API key or access token. > [accordion] forbidden > > * **Status:** 403 > * **Problem:** The server understood the request, but is refusing to fulfill it because the client lacks proper permission. > * **Solution:** Make sure you have the necessary permissions to access the resource. > [accordion] not\_found > > * **Status:** 404 > * **Problem:** The server has not found anything matching the request URI. > * **Solution:** Check the request and make sure the resource exists. > [accordion] conflict > > * **Status:** 409 > * **Problem:** Another resource already uses the same identifier. For example, project slug must be unique. > * **Solution:** Change the identifier to a unique value. > [accordion] invite\_expired > > * **Status:** 410 > * **Problem:** The invite has expired. > * **Solution:** Generate a new invite. > [accordion] unprocessable\_entity > > * **Status:** 422 > * **Problem:** The server was unable to process the request because it contains invalid data. > * **Solution:** Check the request and make sure input data is valid. > [accordion] rate\_limit\_exceeded > > * **Status:** 429 > * **Problem:** The request has been rate limited. > * **Solution:** Wait for a while and try again. > [accordion] internal\_server\_error > > * **Status:** 500 > * **Problem:** The server encountered an unexpected condition that prevented it from fulfilling the request. > * **Solution:** Try again later. If the problem persists, contact support. ## Pagination CodeQR's API supports pagination. This is useful when you have a large number of resources and you want to retrieve them in smaller chunks. These list API methods share a common set of parameters that allow you to control the number of items returned and the page number. For example, you can: * [retrieve a list of links](/api-reference/endpoint/retrieve-a-list-of-links) * [retrieve a list of domains](/api-reference/endpoint/retrieve-a-list-of-domains) * [retrieve a list of events](/api-reference/endpoint/retrieve-a-list-of-events) ### Parameters **page** `string` (default: 1) The page number to retrieve. By default, the first page is returned. **pageSize** `string` The number of items to retrieve per page. The default value varies by endpoint. Maximum value is 100. **sortBy** `string` The field to sort the results by. **sortOrder** `string` The order to sort the results by. Can be `asc` or `desc`. ### Example The following example demonstrates how to retrieve the first page of 10 links: ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/links?page=1&pageSize=10 \ --header 'Authorization: Bearer ' ``` ```javascript Node.js theme={null} const res = await codeqr.links.list({ page: 1, pageSize: 10, }); ``` # Rate limits Source: https://docs.codeqr.io/api-reference/rate-limits Learn about CodeQR's API rate limits. CodeQR's API rate limiting is in conformance with the [IETF standard](https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers): | Header Name | Description | | - | - | | `X-RateLimit-Limit` | The maximum number of requests that the consumer is permitted to make per minute. | | `X-RateLimit-Remaining` | The number of requests remaining in the current rate limit window. | | `X-RateLimit-Reset` | The time at which the current rate limit window resets in UTC epoch seconds. | | `Retry-After` | The number of seconds to wait before retrying the request again. | CodeQR's API is capped at **60 requests per minute** per key on the Free plan, with elevated limits on paid plans (see the table below). This is implemented to ensure a fair usage policy so that excessive use by a single user does not adversely affect the performance and usage of the API by others. You'll receive a `429 Too Many Requests` response code if the rate limit is exceeded. ## Rate limits by plan Depending on your CodeQR plan, you can expect the following rate limits: | Plan | Rate limit | | - | - | | Free | 60 requests per minute | | [Starter](https://codeqr.io/help/article/starter-plan) | 100 requests per minute | | [Pro](https://codeqr.io/help/article/pro-plan) | 500 requests per minute | | [Business](https://codeqr.io/help/article/business-plan) | 1,000 requests per minute | | Scale | 10,000 requests per minute | | [Enterprise](https://codeqr.io/enterprise) | Custom – [reach out to sales](https://codeqr.io/contact/sales) for details | ## How to comply with rate limits Here are some tips on how you can optimize your API setup to comply with our rate limits: ### 1. Bulk link creation If you need to create a lot of links within a short period of time, try our [bulk link creation endpoint](/api-reference/endpoint/bulk-create-links) instead (create up to 100 links in one API call) ```javascript Node.js theme={null} await codeqr.links.createMany([ { url: "https://google.com", }, { url: "https://twitter.com", }, { url: "https://linkedin.com", }, ]); ``` ### 2. Fetch project-level analytics If you're using our [Analytics API](/api-reference/endpoint/retrieve-analytics), instead of retrieving the clicks count for every single link, try making a single API call to get project-level click analytics instead. ```javascript Node.js theme={null} await codeqr.analytics.retrieve({ groupBy: "top_links", start: "4 hours ago", // we support natural language for start/end params }); ``` ### 3. Leverage webhooks If you're expecting high volume, fast-changing data (e.g. thousands of clicks on your links per day) and would prefer to store the data on your end, we recommend using our [real-time webhooks feature](https://codeqr.io/blog/introducing-webhooks) instead. ![Webhook event logs](https://res.cloudinary.com/dhnaggn4g/image/upload/v1753662649/static/webhook-event-logs_dgnqnv.jpg) [Webhooks](/concepts/webhooks/introduction) are *push-based*, meaning that CodeQR will send events to your webhook receiver endpoint when specific events occur, while a REST API is *pull-based*, meaning that you need to consistently poll the API endpoint to get real-time updates. Check out our [webhooks documentation](/concepts/webhooks/introduction) to learn more. # API keys Source: https://docs.codeqr.io/api-reference/tokens Learn how API keys work on CodeQR. API keys on CodeQR allow you to access your project programmatically. This is useful for integrating CodeQR into your application or with other tools and services. Each API key is tied to a specific project – meaning you can use it to access that project's resources without having to worry about "leaking" access to other projects. API keys on CodeQR follow the format: ```bash .env theme={null} CODEQR_API_KEY=codeqr_xxxxxxxx ``` By default, you can use this key to perform any API request without restriction, so it must be stored securely in your app's server-side code (such as in an environment variable or credential management system). Don’t expose this key on a website. ## Create an API key You can create an API key by following these steps: **1. Go to your project** Go to **Settings** > [**API Keys**](https://app.codeqr.io/settings/tokens) in your project. ![Project API keys on CodeQR](https://mintlify.s3.us-west-1.amazonaws.com/codeqr/images/project-api-keys.png) **2. Create an API Key** Click on the "Create" button and select permissions you want to grant to the API key. Select between "You" and "Machine" to associate the API key with your account or a [machine user](#machine-users). * **You**: This API key is tied to your user and can make requests against the selected project. * **Machine**: A machine user will be added to your project, and an API key associated with that machine user will be created. ![Add new API key on CodeQR](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/add-new-api-key.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=853c229517428c95a97b2a3edbf66e96) Click on the **Create API Key** button to create the key. Make sure to copy your API key and store it in a safe place. You won't be able to see it again. ![API Key created on CodeQR](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/api-key-created.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=350990d0783755fd53405f4c54b07b7c) **3. Use your API Key** Now that you have your API key, you can use it to access your project's resources programmatically via SDKs or within any API request as a bearer token. ``` Authorization: Bearer codeqr_xxxx ``` > [!TIP] > > We recommend creating API keys with the least privilege necessary to perform > the required tasks. This helps to reduce the risk of unauthorized access to > your project. ## API key permissions When creating a secret key, you can select the permissions it has, which will give the key access to certain (or all) resources on CodeQR. Here are the different permission options: | Permission | Description | | :- | :- | | **All permissions** | This API key will have full access to all resources. | | **Read only** | This API key will have read-only access to all resources. | | **Restricted** | This API key will have restricted access to some resources: | Depending on your use case, you might want to use one of these 3 options to limit the scope of the API key and improve security. When making API calls, if your API key has insufficient permissions, the error should tell you which permissions you need. > [!TIP] > > You can only set permissions on Secret keys. Publishable keys only have access > to certain endpoints, and cannot be restricted. ## Machine users On CodeQR, you can create API keys that are associated with a "Machine user". This is particularly helpful when you don't want to associate the API key with a particular user in your project, to avoid security risks in involving turnover or changes in project ownership. > [!WARNING] > > Machine users share the same permissions as the [owner > role](https://codeqr.io/help/article/project-roles#owner-role) in a project. > Make sure to only create machine users for trusted applications. ![Creating an API key associated with a machine user on CodeQR](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/api-machine-users.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=7613291a4e07f5fa0caa8fda90da5e05) These machine users will show up on your project's **People** tab, but will not contribute to your project's user count. ![Machine user on CodeQR](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/machine-user.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=1b438c4549c82e71261cd6307b5c406c) > [!TIP] > > If you delete an API key associated with a machine user, the machine user will > be deleted. Vice versa, if you delete a machine user, their corresponding API > key will be deleted as well. # Bulk operations Source: https://docs.codeqr.io/concepts/links/bulk-operations Learn how to perform bulk operations on links. CodeQR allows you to perform bulk operations on links. This is particularly useful when you need to [create](/api-reference/endpoint/bulk-create-links), [update](/api-reference/endpoint/bulk-update-links), or [delete](/api-reference/endpoint/bulk-delete-links) multiple links at once without having to make multiple API requests. ## Bulk create links Bulk create allows you to create up to 100 links at once. > [!WARNING] > > Bulk link creation does not support [custom link > previews](https://codeqr.io/help/article/custom-link-previews). Also, [webhook > events](/concepts/webhooks/introduction) will not be triggered when using bulk > link creation. ```bash cURL theme={null} curl --request POST \ --url https://api.codeqr.io/links/bulk \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' --data '[ { "url": "https://google.com" }, { "url": "https://google.uk" } ]' ``` Check out the [full API reference for the link bulk creation endpoint](/api-reference/endpoint/bulk-create-links). ## Bulk update links Bulk update allows you to modify up to 100 links simultaneously **with the same data**. Some potential use cases: * Tagging multiple links at once * Setting the same expiration date for multiple links * Updating UTM parameters for multiple links > [!WARNING] > > You cannot update the domain or key of a link with this endpoint. Also, > [webhook events](/concepts/webhooks/introduction) will not be triggered when > using bulk link updates ```bash cURL theme={null} curl --request PATCH \ --url https://api.codeqr.io/links/bulk \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"link_ids": ["clux0rgak00011...", "clux0rgak00022..."], "data": {"utm_source": "facebook", "utm_medium": "cpc"}}' ``` Check out the [full API reference for the link bulk update endpoint](/api-reference/endpoint/bulk-update-links). ## Bulk delete links With bulk delete, you can delete up to 100 links at once. > [!WARNING] > > This is a destructive action and cannot be undone. Proceed with caution. Also, > [webhook events](/concepts/webhooks/introduction) will not be triggered when > using this endpoint. ```bash cURL theme={null} curl --request DELETE \ --url https://api.codeqr.io/links/bulk?linkIds=clux0rgak00011... \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` Check out the [full API reference for the link bulk delete endpoint](/api-reference/endpoint/bulk-delete-links). # Introduction Source: https://docs.codeqr.io/concepts/links/introduction Learn how to use CodeQR to programmatically create, update, and delete links at scale. Links are the bread and butter of [CodeQR](https://codeqr.io). Everything on CodeQR starts with a link. Whether you're creating: * a handful of links for your marketing campaign * hundreds of links for your affiliate program * thousands of links, [programmatically](/api-reference/endpoint/bulk-create-links), for your SMS campaign In this guide, we'll cover the link model, how to create links, and more. ## The link model The link model consists of the following properties: | Property | Description | Example | | - | :- | :- | | `id` | The unique identifier of the link (prefixed with `link_`) | `link_eBKA4MT44XnI17hYLchkjUOd` | | `url` | The destination URL of the link | `https://codeqr.io/home` | | `shortLink` | The shortened version of the link (including https) | `https://codeqr.link/claim` | | `domain` | The domain of the link | `codeqr.link` | | `key` | The short link slug | `claim` | For more advanced features like [custom link previews](https://codeqr.io/help/article/custom-link-previews), [conversion tracking](/conversions/quickstart), and more, see the full list of properties [here](/api-reference/endpoint/create-a-link). You can use the various [CodeQR SDKs](/sdks/overview) to programmatically manage your links. ## Create a link The `url` field, representing the destination URL, is the sole mandatory parameter required for the creation of a new short link. ```bash cURL {5} theme={null} curl --request POST \ --url https://api.codeqr.io/links \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://google.com"}' ``` Check out the [full API reference for the link creation endpoint](/api-reference/endpoint/create-a-link). ## Update a link An existing link can be updated by providing the `id` to the `update` method. This method returns the updated link as a response. You can use either the `linkId` or an `externalId` prefixed with `ext_` which is a unique identifier for the link in your own database to associate it with the link in CodeQR's system. ```bash cURL theme={null} curl --request PATCH \ --url https://api.codeqr.io/links/link_eBKA4MT44XnI17hYLchkjUOd \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://www.google.uk"}' ``` Check out the [full API reference for the link update endpoint](/api-reference/endpoint/update-a-link). ## Upsert a link Upserting a link is a combination of creating and updating a link. If a link with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new link will be created. This allows you to use the upsert method without the necessity of checking for the link's existence beforehand. ```bash cURL theme={null} curl --request POST \ --url https://api.codeqr.io/links/update \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://google.com"}' ``` Check out the [full API reference for the link upsert endpoint](/api-reference/endpoint/upsert-a-link). # Organizing links Source: https://docs.codeqr.io/concepts/links/organization Learn how to associate links with users, campaigns, teams, and other entities within your system. When creating links programmatically with CodeQR, you might want a way to associate them with a user or other identifiers in your system. There are a few ways to do this, depending on your data structure: | Method | Type | Description | Use case | | - | - | - | - | | [External ID](#external-id) | One-to-one | A unique identifier for a link within your system. | Associating referral links with users in your system. | | [Tenant ID](#tenant-id) | One-to-many | The ID of the tenant that created the link. | Grouping all links created by a user/team in your system. | | [Tags](#tags) | Many-to-many | Grouping links by tags | Organizing links by campaign / user / various for flexible, multi-dimensional filtering and reporting | ## External ID In certain scenarios, it is essential to identify links within your system. For instance, you may need to associate a link with a user without storing the CodeQR link ID directly in your database (e.g. for referral links). The `externalId` field serves this purpose effectively. It acts as a unique identifier within your database, allowing you to associate it with a corresponding link in CodeQR's system. CodeQR allows you to create links using an `externalId` and subsequently retrieve them by the same identifier. > [!NOTE] > > `externalId` should be a unique value across your project. Trying to create > a link with an externalId that already exists will result in a [`409` conflict > error](/api-reference/introduction#conflict) error. ### Create link with an externalId Here is an example of how to create a link with an `externalId`: ```bash cURL theme={null} curl --request POST \ --url https://api.codeqr.io/links \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "url": "https://google.com", "external_id": "12345" }' ``` ### Retrieve link by externalId Let's see how to retrieve a link by its `externalId`: ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/links/info?external_id=12345 \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` ### Update link by externalId In addition to updating a link by its `linkId`, you can also update a link by its `externalId`. > [!NOTE] > > Make sure to prefix the `externalId` with `ext_`. For example, if your > `externalId` is `12345`, you should pass `ext_12345`. ```bash cURL theme={null} curl --request PATCH \ --url https://api.codeqr.io/links/ext_12345 \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://www.google.uk"}' ``` ### Retrieve analytics by externalId You can also retrieve analytics for a link by its `externalId`. This is helpful for fetching the analytics for a given link using the unique identifier from your system. ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/analytics?external_id=ext_12345 \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` ## Tenant ID The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant. This is useful if you have a system that lets your users create their own links, and you want to group them on a tenant level. ### Create link with tenantId Let's see how to create a link with a tenant ID: ```bash cURL theme={null} curl --request POST \ --url https://api.codeqr.io/links \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "url": "https://google.com", "external_id": "12345" }' ``` ### Retrieve links by tenantId Here is how to retrieve links by tenant ID: ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/links?tenantId=12345 \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` ### Retrieve analytics by tenantId You can retrieve analytics by tenantId by passing the `tenantId` prop. This is helpful for fetching the analytics for all the links under a specific tenant, or the total analytics for a tenant. ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/analytics?tenantId=12345 \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` *** ## Tags Tags are a great way to organize your links on CodeQR. With tags, you can: * Organize your links by campaigns, clients, or any other categories you can think of. * [Filter your links by tags](#retrieve-links-by-tags) and get a shareable link to the filtered results. * [Filter your analytics by tags](#retrieve-analytics-by-tags) to see how your campaigns are performing. ### Create link with tags You can use either pass the tag ID or tag name to create a link with tags. ```bash cURL theme={null} curl --request POST \ --url https://api.codeqr.io/links \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{ "url": "https://example.com", "tagIds": ["clux0rgak00011..."] }' ``` ### Retrieve links by tags You can retrieve links by tag by tags. ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/links?tagNames=tag1 \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` ### Retrieve analytics by tags You can retrieve analytics for a tag (or multiple tags) by passing the `tagIds` prop. This is helpful for fetching the analytics for all the links under a specific tag, or the total analytics for a tag (or multiple tags). ```bash cURL theme={null} curl --request GET \ --url https://api.codeqr.io/analytics?tagIds=tag_xxx \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` # Bulk operations Source: https://docs.codeqr.io/concepts/qrcodes/bulk-operations Learn how to perform bulk operations on QR Codes. CodeQR allows you to perform bulk operations on QR Codes. This is particularly useful when you need to [create](/api-reference/endpoint/bulk-create-qrcodes) or [delete](/api-reference/endpoint/bulk-delete-qrcodes) multiple QR Codes at once without having to make multiple API requests. ## Bulk create QR Codes Bulk create allows you to create up to 100 QR Codes at once. > [!WARNING] > > Bulk QR Code creation does not support [custom QR Code > designs](https://codeqr.io/help/article/custom-qr-designs). Also, [webhook > events](/concepts/webhooks/introduction) will not be triggered when using bulk > QR Code creation. ```bash cURL theme={null} curl --request POST \ --url https://api.codeqr.io/qrcodes/bulk \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' --data '[ { "url": "https://google.com" }, { "url": "https://google.uk" } ]' ``` Check out the [full API reference for the QR Code bulk creation endpoint](/api-reference/endpoint/bulk-create-qrcodes). ## Bulk delete QR Codes With bulk delete, you can delete up to 100 QR Codes at once. > [!WARNING] > > This is a destructive action and cannot be undone. Proceed with caution. Also, > [webhook events](/concepts/webhooks/introduction) will not be triggered when > using this endpoint. ```bash cURL theme={null} curl --request DELETE \ --url https://api.codeqr.io/qrcodes/bulk?qrcodeIds=clux0rgak00011... \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' ``` Check out the [full API reference for the QR Code bulk delete endpoint](/api-reference/endpoint/bulk-delete-qrcodes). # Introduction Source: https://docs.codeqr.io/concepts/qrcodes/introduction Learn how to use CodeQR to programmatically create, update, and manage QR Codes at scale. QR Codes are a core feature of [CodeQR](https://codeqr.io). Everything on CodeQR starts with a QR Code. Whether you're creating: * a single QR Code for your marketing campaign * hundreds of QR Codes for your event registrations * thousands of QR Codes, [programmatically](/api-reference/endpoint/bulk-create-qrcodes), for your product catalog In this guide, we'll cover the QR Code model, how to create QR Codes, and more. ## The QR Code model The QR Code model consists of the following properties: | Property | Description | Example | | - | :- | :- | | `id` | The unique identifier of the QR Code | `cm9zsbu1f00019imtllva1p35` | | `url` | The destination URL encoded in the QR Code | `https://expol.ink/p/rTrlexxQcj` | | `shortLink` | The shortened version of the QR Code link | `https://expol.ink/zfNIPj8Mv24Q-qr` | | `domain` | The domain of the QR Code | `expol.ink` | | `key` | The unique slug for the QR Code | `zfNIPj8Mv24Q-qr` | | `image` | The URL of the generated QR Code image | `https://res.cloudinary.com/.../qr.png` | | `bgColor` | The background color of the QR Code | `#ffffff` | | `fgColor` | The foreground color of the QR Code | `#4a69ff` | | `size` | The size of the QR Code in pixels | `1024` | | `level` | The error correction level of the QR Code | `H` | | `showLogo` | Whether the QR Code includes a logo | `true` | | `scans` | The number of times the QR Code has been scanned | `1` | | `createdAt` | The timestamp when the QR Code was created | `2025-04-27T15:09:08.689Z` | | `updatedAt` | The timestamp when the QR Code was last updated | `2025-04-27T15:09:08.689Z` | For more advanced features like [custom QR Code designs](https://codeqr.io/help/article/custom-qr-designs), scan tracking, and more, see the full list of properties [here](/api-reference/endpoint/create-a-qrcode). You can use the various [CodeQR SDKs](/sdks/overview) to programmatically manage your QR Codes. ## Create a QR Code The `url` field, representing the destination URL, is the sole mandatory parameter required for the creation of a new QR Code. ```bash cURL {5} theme={null} curl --request POST \ --url https://api.codeqr.io/qrcodes \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://google.com"}' ``` Check out the [full API reference for the QR Code creation endpoint](/api-reference/endpoint/create-a-qrcode). ## Update a QR Code An existing QR Code can be updated by providing the `id` to the `update` method. This method returns the updated QR Code as a response. ```bash cURL theme={null} curl --request PATCH \ --url https://api.codeqr.io/qrcodes/cm9zsbu1f00019imtllva1p35 \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://www.google.uk"}' ``` Check out the [full API reference for the QR Code update endpoint](/api-reference/endpoint/update-a-qrcode). ## Upsert a QR Code Upserting a QR Code is a combination of creating and updating a QR Code. If a QR Code with the same URL already exists, return it (or update it if there are any changes). Otherwise, a new QR Code will be created. ```bash cURL theme={null} curl --request POST \ --url https://api.codeqr.io/qrcodes/update \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://google.com"}' ``` Check out the [full API reference for the QR Code upsert endpoint](/api-reference/endpoint/upsert-a-qrcode). # Event types Source: https://docs.codeqr.io/concepts/webhooks/event-types List of available webhook events you can listen to along with their payload examples Webhooks are a great way to get real-time notifications on events that happen in your CodeQR project. Webhooks on CodeQR follow the following format: ```json webhook-payload.json theme={null} { "id": "evt_KleiO4HBwZFbO1vZLWIPZ2AtX", // The event ID "event": "link.created", // The event type "createdAt": "2024-08-26T16:41:52.346Z", // The timestamp of when the event was created "data": { // Event payload } } ``` There are four types of webhook events you can listen to: * [**Project-level events**](#project-level-events) * [**Link-level events**](#link-level-events) * [**QR Code-level events**](#qr-code-level-events) * [**Page-level events**](#page-level-events) > [!NOTE] > > **Plan requirements for subscribing.** Receiving webhook deliveries is not plan-gated, but the events you can *subscribe* to are: > > * CRUD events (`link.*`, `qrcode.*`, `page.*` created/updated/deleted), `lead.created`, and `sale.created` require the **Pro** plan or above. > * High-volume events — `link.clicked`, `qrcode.scanned`, and `page.visited` — require the **Business** plan or above. > * Attaching a specific link, QR Code, or Page to a webhook also requires the **Business** plan or above. ## Project-level events These events are triggered in the context of your entire project: * [`link.created`](#link-created) * [`link.updated`](#link-updated) * [`link.deleted`](#link-deleted) * [`qrcode.created`](#qrcode-created) * [`qrcode.updated`](#qrcode-updated) * [`qrcode.deleted`](#qrcode-deleted) * [`page.created`](#page-created) * [`page.updated`](#page-updated) * [`page.deleted`](#page-deleted) * [`lead.created`](#lead-created) * [`sale.created`](#sale-created) ### `link.created` This event is triggered when a [new link is created](/api-reference/endpoint/create-a-link) in your CodeQR project. The event payload contains the created link's details. Here's an example payload: > [accordion] Sample payload > > ```json link.created theme={null} > { > "id": "evt_KleiO4HBwZFbO1vZLWIPZ2AtX", > "event": "link.created", > "createdAt": "2024-08-26T16:41:52.346Z", > "data": { > "id": "cm0b87844000dismqhkviju54", > "domain": "codeqr.link", > "key": "sOvvXDT", > "externalId": null, > "url": "https://github.com/stack-auth/stack", > "trackConversion": false, > "archived": false, > "expiresAt": null, > "expiredUrl": null, > "password": null, > "proxy": false, > "title": null, > "description": null, > "image": null, > "video": null, > "rewrite": false, > "doIndex": false, > "ios": null, > "android": null, > "geo": null, > "publicStats": false, > "tagId": null, > "tags": [], > "comments": null, > "shortLink": "https://codeqr.link/9KUP86d", > "qrCode": "https://api.codeqr.io/qr?url=https://codeqr.link/9KUP86d?qr=1", > "utm_source": null, > "utm_medium": null, > "utm_campaign": null, > "utm_term": null, > "utm_content": null, > "userId": "cm022rkcw0000ikt14mscg9sg", > "projectId": "cm022sis60003ikt1syy7kfhl", > "clicks": 0, > "lastClicked": null, > "leads": 0, > "sales": 0, > "saleAmount": 0, > "createdAt": "2024-08-26T16:41:52.084Z", > "updatedAt": "2024-08-26T16:41:52.084Z", > "projectId": "cm022sis60003ikt1syy7kfhl" > } > } > ``` ### `link.updated` This event is triggered when a [link is updated](/api-reference/endpoint/update-a-link) in your CodeQR project. The event payload contains the updated link's details. Here's an example payload: > [accordion] Sample payload > > ```json link.updated theme={null} > { > "id": "event_KleiO4HBwZFbO1vZLWIPZ2AtX", > "event": "link.updated", > "createdAt": "2024-08-26T16:41:52.346Z", > "data": { > "id": "cm0b87844000dismqhkviju54", > "domain": "codeqr.link", > "key": "sOvvXDT", > "externalId": null, > "url": "https://github.com/stack-auth/stack", > "trackConversion": false, > "archived": false, > "expiresAt": null, > "expiredUrl": null, > "password": null, > "proxy": false, > "title": null, > "description": null, > "image": null, > "video": null, > "rewrite": false, > "doIndex": false, > "ios": null, > "android": null, > "geo": null, > "publicStats": false, > "tagId": null, > "tags": [], > "comments": null, > "shortLink": "https://codeqr.link/9KUP86d", > "qrCode": "https://api.codeqr.io/qr?url=https://codeqr.link/9KUP86d?qr=1", > "utm_source": null, > "utm_medium": null, > "utm_campaign": null, > "utm_term": null, > "utm_content": null, > "userId": "cm022rkcw0000ikt14mscg9sg", > "projectId": "cm022sis60003ikt1syy7kfhl", > "clicks": 0, > "lastClicked": null, > "leads": 0, > "sales": 0, > "saleAmount": 0, > "createdAt": "2024-08-26T16:41:52.084Z", > "updatedAt": "2024-08-26T16:41:52.084Z", > "projectId": "cm022sis60003ikt1syy7kfhl" > } > } > ``` ### `link.deleted` This event is triggered when a [link is deleted](/api-reference/endpoint/delete-a-link) in your CodeQR project. The event payload contains the deleted link's details. Here's an example payload: > [accordion] Sample payload > > ```json link.deleted theme={null} > { > "id": "evt_KleiO4HBwZFbO1vZLWIPZ2AtX", > "event": "link.deleted", > "createdAt": "2024-08-26T16:41:52.346Z", > "data": { > "id": "cm0b87844000dismqhkviju54", > "domain": "codeqr.link", > "key": "sOvvXDT", > "externalId": null, > "url": "https://github.com/stack-auth/stack", > "trackConversion": false, > "archived": false, > "expiresAt": null, > "expiredUrl": null, > "password": null, > "proxy": false, > "title": null, > "description": null, > "image": null, > "video": null, > "rewrite": false, > "doIndex": false, > "ios": null, > "android": null, > "geo": null, > "publicStats": false, > "tagId": null, > "tags": [], > "comments": null, > "shortLink": "https://codeqr.link/9KUP86d", > "qrCode": "https://api.codeqr.io/qr?url=https://codeqr.link/9KUP86d?qr=1", > "utm_source": null, > "utm_medium": null, > "utm_campaign": null, > "utm_term": null, > "utm_content": null, > "userId": "cm022rkcw0000ikt14mscg9sg", > "projectId": "cm022sis60003ikt1syy7kfhl", > "clicks": 0, > "lastClicked": null, > "leads": 0, > "sales": 0, > "saleAmount": 0, > "createdAt": "2024-08-26T16:41:52.084Z", > "updatedAt": "2024-08-26T16:41:52.084Z", > "projectId": "cm022sis60003ikt1syy7kfhl" > } > } > ``` ### `qrcode.created` This event is triggered when a new QR code is created in your CodeQR project. The event payload contains the created QR code's details (under `data.qrcode`). > [accordion] Sample payload > > ```json qrcode.created theme={null} > { > "id": "evt_KleiO4HBwZFbO1vZLWIPZ2AtX", > "event": "qrcode.created", > "createdAt": "2024-08-26T16:41:52.346Z", > "data": { > "qrcode": { > "id": "cm0pie2xy0007zayvaghkb7d6", > "domain": "expol.ink", > "key": "rXUSTPx1tic3-qr", > "archived": false, > "static": false, > "type": "url", > "url": "https://app.codeqr.io/", > "userId": "clv4ckurp0000nircotd5umkn", > "projectId": "cm0bfj5eg000045ruzb5o8tar", > "scans": 1, > "shortLink": "https://expol.ink/rXUSTPx1tic3-qr", > "createdAt": "2024-09-05T16:35:54.597Z", > "updatedAt": "2024-09-05T16:35:54.597Z" > } > } > } > ``` ### `qrcode.updated` This event is triggered when a QR code is updated in your CodeQR project. The event payload contains the updated QR code's details (under `data.qrcode`). ### `qrcode.deleted` This event is triggered when a QR code is deleted in your CodeQR project. The event payload contains the deleted QR code's details (under `data.qrcode`). ### `page.created` This event is triggered when a new page is created in your CodeQR project. The event payload contains the created page's details (under `data.page`). > [accordion] Sample payload > > ```json page.created theme={null} > { > "id": "evt_KleiO4HBwZFbO1vZLWIPZ2AtX", > "event": "page.created", > "createdAt": "2024-08-26T16:41:52.346Z", > "data": { > "page": { > "id": "cm0snvcxr002jp80474b2dckg", > "domain": "expol.ink", > "key": "p/pHs20VCe8V", > "name": "Deixe seu feedback", > "type": "feedback", > "projectId": "cm0bfj5eg000045ruzb5o8tar", > "userId": "clv4ckurp0000nircotd5umkn", > "views": 1, > "createdAt": "2024-09-07T21:32:37.309Z", > "updatedAt": "2024-09-07T21:32:51.471Z" > } > } > } > ``` ### `page.updated` This event is triggered when a page is updated in your CodeQR project. The event payload contains the updated page's details (under `data.page`). ### `page.deleted` This event is triggered when a page is deleted in your CodeQR project. The event payload contains the deleted page's details (under `data.page`). ### `lead.created` This event is triggered when a [new lead is created](/api-reference/endpoint/track-lead) via [CodeQR Conversions](/conversions/quickstart). The event payload contains the following: * `eventName`: The name of the event that was tracked. * `customer`: Details about the customer that signed up. * `interaction`: The click/scan/view event that led to the lead (same shape as `data.interaction` for link.clicked, qrcode.scanned, page.visited). * `link` / `qrcode` / `page`: Details about the referral resource the lead is associated with, when applicable. Here's an example payload: > [accordion] Sample payload > > ```json lead.created theme={null} > { > "id": "evt_P343bmyae40ALQYr5HT4vRXRd", > "event": "lead.created", > "createdAt": "2024-08-30T09:53:50.343Z", > "data": { > "eventName": "Sign up", > "customer": { > "id": "oU5P0SqI8fpwx5bxw1", > "name": "John", > "email": "john@example.com", > "avatar": "https://example.com/john.jpeg" > }, > "interaction": { > "id": "d0UtZqE0BZuBPrJS", > "url": "https://github.com/codeqr-io/codeqr", > "ip": "63.141.57.109", > "continent": "NA", > "country": "US", > "city": "San Francisco", > "device": "Desktop", > "browser": "Chrome", > "os": "Mac OS", > "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36", > "bot": false, > "qr": false, > "referer": "(direct)" > }, > "link": { > "id": "cm0faqkyn0001txvfwjfeq7gl", > "domain": "codeqr.link", > "key": "79ys3WA", > "externalId": null, > "url": "https://github.com/codeqr-io/codeqr", > "trackConversion": true, > "archived": false, > "expiresAt": null, > "expiredUrl": null, > "password": null, > "proxy": false, > "title": null, > "description": null, > "image": null, > "video": null, > "rewrite": false, > "doIndex": false, > "ios": null, > "android": null, > "geo": null, > "publicStats": false, > "comments": null, > "shortLink": "https://codeqr.link/9KUP86d", > "qrCode": "https://api.codeqr.io/qr?url=https://codeqr.link/9KUP86d?qr=1", > "utm_source": null, > "utm_medium": null, > "utm_campaign": null, > "utm_term": null, > "utm_content": null, > "userId": "cm022rkcw0000ikt14mscg9sg", > "projectId": "cm022sis60003ikt1syy7kfhl", > "clicks": 10, > "lastClicked": "2024-08-30T07:45:09.000Z", > "leads": 5, > "sales": 0, > "saleAmount": 0, > "createdAt": "2024-08-29T13:03:59.098Z", > "updatedAt": "2024-08-30T09:53:49.505Z" > } > } > } > ``` ### `sale.created` This event is triggered when a [new sale is tracked](/api-reference/endpoint/track-sale) via [CodeQR Conversions](/conversions/quickstart). The event payload contains the following: * `eventName`: Optional; the name of the event that was tracked. * `customer`: Details about the customer that made the purchase. * `interaction`: Optional; the click/scan/view event that led to the sale (when available; e.g. not sent from Stripe checkout). * `link` / `qrcode` / `page`: Details about the referral resource the sale is associated with, when applicable. * `sale`: Amount, currency, payment processor, invoice ID. Here's an example payload: > [accordion] Sample payload > > ```json sale.created theme={null} > { > "id": "evt_WHjyHhqsfYOrlJOOVJSoHXysD", > "event": "sale.created", > "createdAt": "2024-08-30T09:57:51.245Z", > "data": { > "eventName": "Purchased", > "customer": { > "id": "cm0gjdvr20001dkbha2n9gt2b", > "name": "John", > "email": "john@example.com", > "avatar": "https://example.com/john.jpeg" > }, > "interaction": { > "id": "d0UtZqE0BZuBPrJS", > "url": "https://github.com/codeqr-io/codeqr", > "ip": "63.141.57.109", > "continent": "NA", > "country": "US", > "city": "San Francisco", > "device": "Desktop", > "browser": "Chrome", > "os": "Mac OS", > "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36", > "bot": false, > "qr": false, > "referer": "(direct)" > }, > "link": { > "id": "cm0faqkyn0001txvfwjfeq7gl", > "domain": "codeqr.link", > "key": "79ys3WA", > "externalId": null, > "url": "https://github.com/codeqr-io/codeqr", > "trackConversion": true, > "archived": false, > "expiresAt": null, > "expiredUrl": null, > "password": null, > "proxy": false, > "title": null, > "description": null, > "image": null, > "video": null, > "rewrite": false, > "doIndex": false, > "ios": null, > "android": null, > "geo": null, > "publicStats": false, > "comments": null, > "shortLink": "https://codeqr.link/9KUP86d", > "qrCode": "https://api.codeqr.io/qr?url=https://codeqr.link/9KUP86d?qr=1", > "utm_source": null, > "utm_medium": null, > "utm_campaign": null, > "utm_term": null, > "utm_content": null, > "userId": "cm022rkcw0000ikt14mscg9sg", > "projectId": "cm022sis60003ikt1syy7kfhl", > "clicks": 10, > "lastClicked": "2024-08-30T07:45:09.000Z", > "leads": 5, > "sales": 1, > "saleAmount": 20000, > "createdAt": "2024-08-29T13:03:59.098Z", > "updatedAt": "2024-08-30T09:57:50.891Z" > }, > "sale": { > "amount": 4500, > "currency": "usd", > "payment_processor": "stripe", > "invoice_id": null > } > } > } > ``` ## Payload field: `interaction` **"Interaction" is not an event type.** It is a field inside the `data` object that we send for click, scan, and view events. We always use the same key **`data.interaction`** and the same structure (the click-event shape: timestamp, clickId, url, ip, continent, country, city, device, browser, os, ua, bot, qr, referer, etc.) for: * **Link-level** `link.clicked` — `data.interaction` (click event) + `data.link` * **QR Code-level** `qrcode.scanned` — `data.interaction` (scan event, same shape) + `data.qrcode` * **Page-level** `page.visited` — `data.interaction` (view event, same shape) + optionally `data.page` * **Project-level** `lead.created` — `data.interaction` (the click that led to the lead) + `data.customer`, `data.link` / `data.qrcode` / `data.page` We do **not** send `data.click`, `data.scan`, or `data.view`; we send **`data.interaction`** for all of these. We do not send a separate webhook event named "interaction". Only the event types listed in this document are sent. ## Link-level events Due to the high volume nature of these events, these events are scoped to a specific link. This means that you need to specify the link when creating a webhook – though you can select multiple links for the same webhook if you'd like. ### `link.clicked` This event is triggered when a user clicks on a link. The event payload contains `data.interaction` (the click event) and `data.link` (full link details). Here's an example payload: > [accordion] Sample payload > > ```json link.clicked theme={null} > { > "id": "evt_b9ywgxWqai2glUpCQjclB17kM", > "event": "link.clicked", > "createdAt": "2024-08-30T10:16:13.149Z", > "data": { > "eventName": "Link clicked", > "interaction": { > "timestamp": "2024-08-30T10:16:12.124Z", > "clickId": "d0UtZqE0BZuBPrJS", > "url": "https://github.com/codeqr-io/codeqr", > "ip": "63.141.57.109", > "continent": "NA", > "country": "US", > "city": "San Francisco", > "device": "Desktop", > "browser": "Chrome", > "os": "Mac OS", > "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36", > "bot": false, > "qr": false, > "referer": "(direct)" > }, > "link": { > "id": "cm0faqkyn0001txvfwjfeq7gl", > "domain": "codeqr.link", > "key": "79ys3WA", > "externalId": null, > "url": "https://github.com/codeqr-io/codeqr", > "trackConversion": true, > "archived": false, > "expiresAt": null, > "expiredUrl": null, > "password": null, > "proxy": false, > "title": null, > "description": null, > "image": null, > "video": null, > "rewrite": false, > "doIndex": false, > "ios": null, > "android": null, > "geo": null, > "publicStats": false, > "comments": null, > "shortLink": "https://codeqr.link/9KUP86d", > "qrCode": "https://api.codeqr.io/qr?url=https://codeqr.link/9KUP86d?qr=1", > "utm_source": null, > "utm_medium": null, > "utm_campaign": null, > "utm_term": null, > "utm_content": null, > "userId": "cm022rkcw0000ikt14mscg9sg", > "projectId": "cm022sis60003ikt1syy7kfhl", > "clicks": 11, > "lastClicked": "2024-08-30T07:45:09.000Z", > "leads": 6, > "sales": 10, > "saleAmount": 200000, > "createdAt": "2024-08-29T13:03:59.098Z", > "updatedAt": "2024-08-30T10:16:12.126Z" > } > } > } > ``` ## QR Code-level events Due to the high volume nature of these events, they are scoped to a specific QR code. You need to specify the QR code(s) when creating a webhook. ### `qrcode.scanned` This event is triggered when a user scans a QR code. The event payload contains `data.interaction` (the scan event, same shape as click event) and `data.qrcode` (full QR code details). > [accordion] Sample payload > > ```json qrcode.scanned theme={null} > { > "id": "evt_b9ywgxWqai2glUpCQjclB17kM", > "event": "qrcode.scanned", > "createdAt": "2024-08-30T10:16:13.149Z", > "data": { > "eventName": "QR code scanned", > "interaction": { > "timestamp": "2024-08-30T10:16:12.124Z", > "clickId": "d0UtZqE0BZuBPrJS", > "url": "https://github.com/deusdete/codeqr", > "ip": "63.141.57.109", > "continent": "NA", > "country": "US", > "city": "San Francisco", > "device": "Desktop", > "browser": "Chrome", > "os": "Mac OS", > "bot": false, > "qr": false, > "referer": "(direct)" > }, > "qrcode": { > "id": "cm0pie2xy0007zayvaghkb7d6", > "domain": "expol.ink", > "key": "rXUSTPx1tic3-qr", > "url": "https://app.codeqr.io/", > "shortLink": "https://expol.ink/rXUSTPx1tic3-qr", > "scans": 1, > "projectId": "cm0bfj5eg000045ruzb5o8tar", > "userId": "clv4ckurp0000nircotd5umkn" > } > } > } > ``` ## Page-level events Due to the high volume nature of these events, they are scoped to a specific page. You need to specify the page(s) when creating a webhook. ### `page.visited` This event is triggered when a user visits a page. The event payload contains `data.interaction` (the view event, same shape as click event) and optionally `data.page` (full page details). > [accordion] Sample payload > > ```json page.visited theme={null} > { > "id": "evt_b9ywgxWqai2glUpCQjclB17kM", > "event": "page.visited", > "createdAt": "2024-08-30T10:16:13.149Z", > "data": { > "eventName": "Page visited", > "interaction": { > "timestamp": "2024-08-30T10:16:12.124Z", > "clickId": "d0UtZqE0BZuBPrJS", > "url": "https://github.com/deusdete/codeqr", > "ip": "63.141.57.109", > "continent": "NA", > "country": "US", > "city": "San Francisco", > "device": "Desktop", > "browser": "Chrome", > "os": "Mac OS", > "bot": false, > "qr": false, > "referer": "(direct)" > }, > "page": { > "id": "cm0snvcxr002jp80474b2dckg", > "domain": "expol.ink", > "key": "p/pHs20VCe8V", > "name": "Deixe seu feedback", > "type": "feedback", > "views": 1, > "projectId": "cm0bfj5eg000045ruzb5o8tar", > "userId": "clv4ckurp0000nircotd5umkn" > } > } > } > ``` # Introduction Source: https://docs.codeqr.io/concepts/webhooks/introduction Use webhooks to get real-time notifications on events happening across your CodeQR project. Webhooks allows you to listen to real-time events happening across your CodeQR project. With webhooks, you can build custom integrations with CodeQR, such as: * Triggering a Zap on [Zapier](https://codeqr.io/integrations/zapier) when a new link is created in CodeQR * Sending click events in real-time to [Segment](https://codeqr.io/integrations/segment) for further processing * Get a [Slack](https://codeqr.io/integrations/slack) notification when someone clicks on your pitch deck link * Building gamified referral programs with [CodeQR Conversions](/conversions/quickstart) – e.g. increment usage credits for the referrer when a [new signup](/conversions/leads) happens > [!WARNING] > > The following endpoints do not trigger webhook events: [Bulk create > links](/api-reference/endpoint/bulk-create-links), [Bulk update > links](/api-reference/endpoint/bulk-update-links), [Bulk delete > links](/api-reference/endpoint/bulk-delete-links). In this guide, we'll show you how to configure webhooks for your CodeQR project and a list of available events you can listen to. > [!NOTE] > > **Plan requirements.** Receiving webhook deliveries is not plan-gated, but the events you can *subscribe* to are. CRUD events, `lead.created`, and `sale.created` require the **Pro** plan or above. High-volume events (`link.clicked`, `qrcode.scanned`, `page.visited`) — and attaching a specific link, QR Code, or Page to a webhook — require the **Business** plan or above. See [Event types](/concepts/webhooks/event-types) for the full breakdown. ## Creating a webhook To create a webhook for your CodeQR project, you'll need to follow these steps: Navigate to the [**Webhooks** settings page](https://app.codeqr.io/webhooks) in your CodeQR project. ![Create Webhook](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/create-webhook.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=ea8690af427b3d0ed89fb05aa553256a) Click on **Create Webhook** to create a new webhook. ![Create Webhook Form](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/create-webhook-form.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=927ea9dea868eced18895ef4efe0e587) Fill in the required fields in the webhook creation form: 1. **Name**: Give your webhook a name that helps you identify it. 2. **URL**: Enter the URL of the endpoint where you want to send the webhook. We recommend using [webhook.site](https://webhook.site/) to test your webhook. 3. **Signing secret**: This is an auto-generated secret key that you can use to verify the authenticity of the webhook in your application. Learn more about [verifying webhook requests](/concepts/webhooks/verify-webhook-requests). 4. **Events**: Select the events you want to listen to. You can select multiple events. Refer to the [Event Types](/concepts/webhooks/event-types) section to see the list of available events. Finally, click on **Create webhook** to create the webhook. ## Viewing webhook event logs We also provide you with a webhook event logs page where you can view all the webhook events that have been sent to your webhook endpoint in real-time. To view the webhook event logs, select the webhook from the [**Webhooks** settings page](https://app.codeqr.io/webhooks) and click on the **Webhook Logs** tab. Here, you'll see a list of all the webhook events that have been sent to your webhook endpoint: ![Webhook Event Logs](https://mintcdn.com/codeqr/ueJ_ilTLXJXEjrH8/images/webhook-event-logs.png?fit=max\&auto=format\&n=ueJ_ilTLXJXEjrH8\&q=85\&s=7a9abe41142bfa35a2e8f6159ca985bf) You can also select on a specific event, which will open up a sheet with more details about the event: ![Webhook Event Logs Details](https://mintcdn.com/codeqr/ueJ_ilTLXJXEjrH8/images/webhook-event-logs-details.png?fit=max\&auto=format\&n=ueJ_ilTLXJXEjrH8\&q=85\&s=4c70fbd5dd4457fdf0a8bae13a1b740d) ## Sending test events You can send test events to your webhook URL to ensure that it's working correctly. To do this: **1. Go to the webhook details page** Navigate to the [**Webhooks** settings page](https://app.codeqr.io/webhooks) and select the webhook you want to test. Click on the **Update Details** tab to open the webhook details page. **2. Open the test event modal** Select the `⋮` icon on the top right of the page, and click on **Send test event**. ![Send Test Event](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/send-test-event.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=25d185412027cb9ef9d2f667f297e95f) This will open up a modal where you can select the event you want to send. ![Send Test Event Modal](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/send-test-event-modal.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=0cfdc1a1233f19bc9cf00a79a46bce80) **3. Send the test event** Select the event you want to send, and click on **Send test webhook**. ![Send Test Webhook](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/send-test-webhook.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=342f475800976abb171dc4c7ca2780d3) You'll see a success message and receive the webhook event in the webhook endpoint you specified. ## Retry Behaviour If your webhook endpoint does not respond with a success status code (2XX), we retry the request to ensure every message will be delivered. You can see all the retry attempts in your webhook event logs. Webhooks are retried until they are successfully delivered – with an exponential backoff to avoid overwhelming your webhook endpoint (also known as the "[thundering herd problem](https://en.wikipedia.org/wiki/Thundering_herd_problem)"). The delay is capped at 24 hours from the 5th retry attempt onwards. | Retry attempt | Delay | | - | - | | 1st | 12s | | 2nd | 2m 28s | | 3rd | 30m 8s | | 4th | 6h 7m 6s | | 5th | 24h | | 6th | 24h | | ... | ... | ### Temporary Disablement If a webhook endpoint consistently fails, it will be automatically disabled after a series of failed attempts. Notifications will be sent to the Project owners at the following intervals: * After 5, 10, and 15 consecutive failed attempts. * On the 20th consecutive failed attempt, the **webhook will be disabled**. This mechanism ensures that non-responsive endpoints do not continue to receive retry attempts indefinitely, maintaining system efficiency and preventing unnecessary load on both the sender and receiver. You can re-enable a disabled webhook by clicking on the **Enable webhook** button in the webhook details page. # Verify webhook requests Source: https://docs.codeqr.io/concepts/webhooks/verify-webhook-requests Learn how to verify webhook requests to ensure they're coming from CodeQR. With signature verification, you can determine if the webhook came from CodeQR, and has not been tampered with in transit. All webhooks are delivered with a `CodeQR-Signature` header. CodeQR generates this header using a secret key that only you and CodeQR know. An example header looks like this: ``` CodeQR-Signature: c9ed6a2abf93f59d761eea69908d8de00f4437b5b6d7cd8b9bf5719cbe61bf46 ``` ## Finding your webhook's signing secret You can find your webhook's signing secret in the **Update Details** tab: ![Webhook signing secret](https://mintcdn.com/codeqr/ueJ_ilTLXJXEjrH8/images/webhook-signing-secret.png?fit=max\&auto=format\&n=ueJ_ilTLXJXEjrH8\&q=85\&s=b7e55cedbaf8a6340f2843a0a866ac94) Make sure to keep this secret safe by only storing it in a secure environment variable (e.g. `CODEQR_WEBHOOK_SECRET`). Do not commit it to git or add it in any client-side code. ## Verifying a webhook request To verify, you can use the secret key to generate your own signature for each webhook. If both signatures match then you can be sure that a received event came from CodeQR. The steps required are: 1. Get the raw body of the request. 2. Extract the signature from the `CodeQR-Signature` header. 3. Calculate the HMAC of the raw body using the `SHA-256` hash function and the secret. 4. Compare the calculated `HMAC` with the one sent in the `CodeQR-Signature` header. If they match, the webhook is verified. Here's an example of how you can verify a webhook request in different languages: ```javascript Next.js theme={null} export const POST = async (req: Request) => { const webhookSignature = req.headers.get("CodeQR-Signature"); if (!webhookSignature) { return new Response("No signature provided.", { status: 401 }); } // Copy this from the webhook details page const secret = process.env.CODEQR_WEBHOOK_SECRET; if (!secret) { return new Response("No secret provided.", { status: 401 }); } // Make sure to get the raw body from the request const rawBody = await req.text(); const computedSignature = crypto .createHmac("sha256", secret) .update(rawBody) .digest("hex"); if (webhookSignature !== computedSignature) { return new Response("Invalid signature", { status: 400 }); } // Handle the webhook event // ... }; ``` ```python Python theme={null} import hmac import hashlib def webhook(): # Get the signature from the header webhook_signature = request.headers.get('CodeQR-Signature') if not webhook_signature: abort(401, 'No signature provided.') # Copy this from the webhook details page secret = os.environ.get('CODEQR_WEBHOOK_SECRET') if not secret: abort(401, 'No secret provided.') # Get the raw body of the request raw_body = request.data # Calculate the HMAC computed_signature = hmac.new( secret.encode('utf-8'), raw_body, hashlib.sha256 ).hexdigest() if webhook_signature != computed_signature: abort(400, 'Invalid signature') # Handle the webhook event # ... return 'OK', 200 ``` ```go Go theme={null} import ( "crypto/hmac" "crypto/sha256" "encoding/hex" "io/ioutil" "net/http" "os" ) func webhookHandler(w http.ResponseWriter, r *http.Request) { // Get the signature from the header webhookSignature := r.Header.Get("CodeQR-Signature") if webhookSignature == "" { http.Error(w, "No signature provided.", http.StatusUnauthorized) return } // Copy this from the webhook details page secret := os.Getenv("CODEQR_WEBHOOK_SECRET") if secret == "" { http.Error(w, "No secret provided.", http.StatusUnauthorized) return } // Read the raw body body, err := ioutil.ReadAll(r.Body) if err != nil { http.Error(w, "Error reading request body", http.StatusInternalServerError) return } // Calculate the HMAC h := hmac.New(sha256.New, []byte(secret)) h.Write(body) computedSignature := hex.EncodeToString(h.Sum(nil)) if webhookSignature != computedSignature { http.Error(w, "Invalid signature", http.StatusBadRequest) return } // Handle the webhook event // ... w.WriteHeader(http.StatusOK) w.Write([]byte("OK")) } ``` ## Why is signature verification important? Signature verification is a crucial security measure that protects against request forgery and data tampering. Without verification, malicious actors could send fake webhook events to your endpoint, potentially triggering unauthorized actions. The HMAC-SHA256 signature verification process ensures that only CodeQR can generate valid webhook requests and that payloads haven't been modified in transit. This provides both authentication (confirming the sender is CodeQR) and integrity (ensuring the message hasn't been tampered with). # Introduction Source: https://docs.codeqr.io/integrations Integrate CodeQR with your favorite tools and services. Integrations allow you to extend the capabilities of CodeQR and seamlessly connect with third-party platforms and services. By leveraging these integrations, you can enhance your workflows, automate tasks, connect with your favorite tools, and more. ## Official integrations These are the integrations that are officially supported and actively maintained by CodeQR. > [card] [Make](https://codeqr.io/integrations/make) > > Integrate CodeQR with Make > [card] [Zapier](https://codeqr.io/integrations/zapier) > > Integrate CodeQR with Zapier > [card] [Stripe](https://codeqr.io/integrations/stripe) > > Integrate CodeQR with Stripe > [card] [Slack](https://codeqr.io/integrations/slack) > > Integrate CodeQR with Slack > [card] [Kiwify](https://codeqr.io/integrations/kiwify) > > Integrate CodeQR with Kiwify > [card] [IFTTT](https://codeqr.io/integrations/ifttt) > > Integrate CodeQR with IFTTT > [card] [Pluga Webhooks](https://codeqr.io/integrations/pluga) > > Integrate CodeQR with Pluga Webhooks > [card] [n8n](https://codeqr.io/integrations/n8n) > > Integrate CodeQR with n8n > [card] [ActiveCampaign](https://codeqr.io/integrations/activecampaign) > > Integrate CodeQR with ActiveCampaign > [card] [RD Station](https://codeqr.io/integrations/rdstation) > > Integrate CodeQR with RD Station > [card] [Meta Ads](https://codeqr.io/integrations/meta-ads) > > Integrate CodeQR with Meta Ads > [card] [Kommo](https://codeqr.io/integrations/kommo) > > Integrate CodeQR with Kommo > [card] [HubSpot](https://codeqr.io/integrations/hubspot) > > Integrate CodeQR with HubSpot > [card] [monday.com](https://codeqr.io/integrations/monday-com) > > Integrate CodeQR with monday.com > [card] [Albato](https://codeqr.io/integrations/albato) > > Integrate CodeQR with Albato > [card] [Bubble](https://codeqr.io/integrations/bubble) > > Integrate CodeQR with Bubble > [card] [Telebot](https://codeqr.io/integrations/telebot) > > Integrate CodeQR with Telebot > [card] [Integrately](https://codeqr.io/integrations/integrately) > > Integrate CodeQR with Integrately ## AI assistants Connect CodeQR to Claude, ChatGPT, Cursor, Gemini Enterprise, or any other AI assistant that speaks the Model Context Protocol. > [card] [MCP server](/mcp/introduction) > > Create links and QR codes, and read analytics, straight from a conversation ## Building your own integrations You can build your own integrations with CodeQR's infrastructure for both **links** and **QR Codes** using our [API](/api-reference/introduction). 1. Read the documentation on how to [create links](/api-reference/endpoint/create-a-link) or [create QR Codes](/api-reference/endpoint/create-a-qrcode). 2. Learn how to [integrate CodeQR into your application](/integrations/quickstart). 3. [Reach out to us](https://codeqr.io/contact/support) to feature your integration in the integrations marketplace. ## Integration webhooks CodeQR also supports webhooks for integrations. You can use these webhooks to track events for both links and QR Codes. Learn more in the [webhooks](/concepts/webhooks/introduction) documentation. Here's a list of the webhooks that CodeQR supports: * [`link.created`](/concepts/webhooks/event-types#link-created) – when a new link is created * [`link.updated`](/concepts/webhooks/event-types#link-updated) – when a link is updated * [`link.deleted`](/concepts/webhooks/event-types#link-deleted) – when a link is deleted * [`link.clicked`](/concepts/webhooks/event-types#link-clicked) – when a link is clicked * [`qrcode.created`](/concepts/webhooks/event-types#qrcode-created) – when a new QR Code is created * [`qrcode.updated`](/concepts/webhooks/event-types#qrcode-updated) – when a QR Code is updated * [`qrcode.deleted`](/concepts/webhooks/event-types#qrcode-deleted) – when a QR Code is deleted * [`qrcode.scanned`](/concepts/webhooks/event-types#qrcode-scanned) – when a QR Code is scanned * [`page.created`](/concepts/webhooks/event-types#page-created) – when a new page is created * [`page.updated`](/concepts/webhooks/event-types#page-updated) – when a page is updated * [`page.deleted`](/concepts/webhooks/event-types#page-deleted) – when a page is deleted * [`page.visited`](/concepts/webhooks/event-types#page-visited) – when a page is visited * [`lead.created`](/concepts/webhooks/event-types#lead-created) – when a new lead is created * [`sale.created`](/concepts/webhooks/event-types#sale-created) – when a new sale is created # Build your own integration Source: https://docs.codeqr.io/integrations/quickstart Learn how to authenticate users with OAuth 2.0 for your CodeQR integration. Integrations allow you to extend the capabilities of CodeQR and seamlessly connect with third-party platforms and services. You can build your own integrations with CodeQR using our [API](/api-reference/introduction). 1. Read the documentation on how to [create links](/api-reference/endpoint/create-a-link) or [create QR Codes](/api-reference/endpoint/create-a-qrcode). 2. Learn how to [integrate CodeQR into your application](/integrations/quickstart). 3. [Reach out to us](https://codeqr.io/contact/support) to feature your integration in the integrations marketplace. In this guide, you will learn how to create and manage integrations on CodeQR, allowing you to incorporate CodeQR's link attribution platform and QR Code management into your application. ## Integrating via OAuth 2.0 (recommended) CodeQR supports OAuth 2.0 authentication, which is **recommended** if you build integrations extending CodeQR's functionality. We recommend you use an OAuth client library to integrate the OAuth flow. You can find recommended libraries in a variety of programming languages [here](https://oauth.net/code/). ### Set up OAuth 2.0 Here is a step-by-step guide on how to set up OAuth 2.0 authentication with CodeQR. **1. Create an OAuth2 application in CodeQR** * Go to the [OAuth Apps tab](https://app.codeqr.io/settings/oauth-apps) in your project. * Click on **Create OAuth App**. * Fill in the required fields to create an OAuth2 application. **2. Redirect users to authorization URL** When you want to authenticate a user, you need to redirect them to the CodeQR OAuth authorization URL. ``` GET https://app.codeqr.io/oauth/authorize ``` Parameters: | Property | Description | | - | - | | `client_id` | The client ID of your OAuth application. | | `redirect_uri` | The URL to redirect the user to after they authorize the application. | | `response_type` | Expected response type. It should be `code`. | | `scope` | A space-separated list of scopes that you want to request access to. | | `state` | The state parameter to prevent against CSRF attacks. | An example URL would look like this: ``` GET https://app.codeqr.io/oauth/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=SOME_SCOPE&state=SOME_STATE ``` ![OAuth consent screen](https://mintcdn.com/codeqr/Dit-PkrrSHQLOViA/images/oauth-consent.png?fit=max\&auto=format\&n=Dit-PkrrSHQLOViA\&q=85\&s=b3c1a5e63d9ae35a071f8cd99e30bbf7) **3. Exchange code for an access token** The `code` parameter is returned in the query string when the user is redirected back to your application. You can exchange this code for an access token by making a POST request to the CodeQR OAuth token URL. ``` POST https://api.codeqr.io/oauth/token ``` > [!WARNING] > > The `Content-Type` header should be set to `application/x-www-form-urlencoded`. Parameters: | Property | Description | | - | - | | `code` | The code you received when the user was redirected back to your application. | | `client_id` | The client ID of your OAuth application. | | `client_secret` | The client secret of your OAuth application. | | `redirect_uri` | The same redirect URI you used in the authorization URL. | | `grant_type` | The grant type. It should be `authorization_code`. | Response: After a successful request, you will receive a JSON response with the access token. ```json theme={null} { "access_token": "codeqr_access_token_ae8ebf6f97e6200d886ef48a5...", "refresh_token": "7f5acfbe14bca0a20fe6e430ddb7bb494eed160bd...", "token_type": "Bearer", "expires_in": 604800, "scope": "projects.read,projects.write,links.read,links.write,qrcodes.read,qrcodes.write,pages.read,pages.write,tags.read,tags.write" } ``` We recommend using the [PKCE](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce) flow for native desktop or mobile applications or single-page apps (SPAs) where the `client_secret` cannot be hidden. **4. Make an API request with the access token** Once you have obtained a valid access token, you can use it to make requests to the CodeQR API. Here is an example of how you can create a QR Code by passing the access token in the header: `Authorization: Bearer ` ```shell theme={null} curl --request POST \ --url https://api.codeqr.io/qrcodes \ --header 'Authorization: Bearer ' \ --header 'Content-Type: application/json' \ --data '{"url": "https://example.com"}' ``` **5. Refresh the access token** CodeQR access tokens are short-lived, depending on the `expires_in` value (the default value is **604,800 seconds**, or **7 days**). CodeQR will respond with `401 Unauthorized` if you try to use an expired access token. To refresh the access token, you need to make a POST request to the CodeQR OAuth token URL with the `refresh_token` you obtained when exchanging the code for an `access_token`. ``` POST https://api.codeqr.io/oauth/token ``` > [!WARNING] > > The `Content-Type` header should be set to `application/x-www-form-urlencoded`. Parameters: | Property | Description | | - | - | | `client_id` | The client ID of your OAuth application. | | `client_secret` | The client secret of your OAuth application. | | `grant_type` | The grant type. It should be `refresh_token`. | | `refresh_token` | The refresh token you received when exchanging the code for an access token. | Response: After a successful request, you will receive a JSON response with the new access token. ```json theme={null} { "access_token": "codeqr_access_token_ae8ebf6f97e6200d886ef48a5...", "refresh_token": "7f5acfbe14bca0a20fe6e430ddb7bb494eed160bd...", "token_type": "Bearer", "expires_in": 604800, "scope": "projects.read,projects.write,links.read,links.write,qrcodes.read,qrcodes.write,pages.read,pages.write,tags.read,tags.write" } ``` This will invalidate the old access token and refresh token. ### Scopes You can request access to specific scopes when redirecting users to the CodeQR OAuth authorization URL. Scopes are permissions that the user needs to grant to your application. CodeQR supports the following scopes for OAuth 2.0: | Scope | Description | | - | - | | `projects.read` | Read access to projects. | | `projects.write` | Write access to projects. | | `links.read` | Read access to links. | | `links.write` | Write access to links. | | `qrcodes.read` | Read access to QR Codes. | | `qrcodes.write` | Write access to QR Codes. | | `tags.read` | Read access to tags. | | `tags.write` | Write access to tags. | | `pages.read` | Read access to pages. | | `pages.write` | Write access to pages. | | `analytics.read` | Read access to analytics. | | `domains.read` | Read access to domains. | | `domains.write` | Write access to domains. | | `conversions.write` | Record lead and sale conversion events on your behalf. | | `webhooks.read` | Read access to webhooks. | | `webhooks.write` | Write access to webhooks. | | `user.read` | Read access to user information. This scope is included by default. | ## Integrating via API keys (not recommended) CodeQR also supports API key authentication; however, it is **not recommended** for building integrations. It should only be used for internal integrations or personal projects that do not require user consent. Learn more about [API Keys](/api-reference/tokens). # Introduction Source: https://docs.codeqr.io/introduction CodeQR is the platform for managed QR Codes and short links. Your workflow creates them through the API, Make, or Zapier. You change where they point after printing. And you see every scan. [CodeQR](https://codeqr.io) is the modern platform for creating and managing **dynamic QR Codes**. The image gets printed once — but your workflow creates the codes through the API, Make, or Zapier, you change where they point whenever you need to, and you see every scan. But QR Codes are just the start. CodeQR also gives you the power to manage **dynamic short links**, build **personalized landing pages**, and measure every interaction with **real-time analytics**. Whether you are: * a developer generating QR Codes and links programmatically from your own app * an automation builder wiring CodeQR into Make, Zapier, or Airtable * a marketer launching QR-powered campaigns * a creator or founder connecting an audience through QR and links CodeQR helps you engage smarter, measure deeper, and grow faster. ## Key features A generator hands you an image and walks away. With CodeQR the image is the only part that can’t change — **the destination, the data, and the automation behind it stay yours**. Here’s what you can do with CodeQR: * Create **dynamic QR Codes** that you can edit after printing * Track scans with **real-time QR analytics** * Build **personalized landing pages** for your QR campaigns * Generate and manage **short links** ([bulk operations](/concepts/links/bulk-operations)) * Set up **conversion tracking** to measure impact * Automate workflows with **Webhooks** and [integrations](https://codeqr.io/integrations) * Access everything programmatically with our **REST API** and [native SDKs](/sdks/overview) ## Getting started Start in the way that works best for you: > [card] [Create QR Codes](/concepts/qrcodes/introduction) > > Learn how to generate and manage dynamic QR Codes with CodeQR > [card] [Create Short Links](/concepts/links/introduction) > > Get started with short links and manage them at scale > [card] [Try our API](/api-reference/introduction) > > Use CodeQR's API to create, edit, and track QR Codes and links > [card] [Conversion tracking](/conversions/quickstart) > > Follow our quickstart guide to measure conversions ## Stay up to date > [card] [Read our blog](https://codeqr.io/blog) > > Discover product updates, tutorials, and best practices > [card] [Follow us on X/Twitter](https://x.com/codeqr_io) > > Get real-time updates and feature announcements # Gemini Enterprise Source: https://docs.codeqr.io/mcp/gemini-enterprise Connect CodeQR to Gemini Enterprise as a custom MCP server. Gemini Enterprise connects to CodeQR as a **custom MCP server**. It differs from the clients in the [introduction](/mcp/introduction) in one way that changes the setup: it asks for a client ID up front instead of registering itself, so you create one first with a single command. > [!NOTE] > > Gemini Enterprise supports **Streamable HTTP only** — the transport CodeQR speaks. The legacy SSE transport is not supported by either side. ## Step 1 — Create a client ID Gemini Enterprise sends users back to a fixed callback URL after they sign in. Register that URL with CodeQR to get a client ID: ```bash theme={null} curl -X POST https://mcp.codeqr.io/oauth/register \ -H "Content-Type: application/json" \ -d '{ "client_name": "Gemini Enterprise", "redirect_uris": [ "https://vertexaisearch.cloud.google.com/oauth-redirect", "https://vertexaisearch.cloud.google.com/static/oauth/oauth.html" ] }' ``` You get back a `client_id` starting with `codeqr_`. Keep it — you will paste it in step 2. ```json theme={null} { "client_id": "codeqr_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "client_name": "Gemini Enterprise", "token_endpoint_auth_method": "none", "grant_types": ["authorization_code"], "response_types": ["code"] } ``` > [!WARNING] > > Register the callback URL **exactly** as Gemini Enterprise shows it in its setup screen. CodeQR checks the redirect URI against what you registered before it echoes anything back, so a mismatch fails the sign-in with `redirect_uri does not match any URI registered for this client`. If your tenant shows a different callback, register that one instead. ## Step 2 — Add the MCP server In Gemini Enterprise, go to **Data stores → Create data store**, choose **Custom MCP Server**, and fill in: | Field | Value | | - | - | | **MCP Server URL** | `https://mcp.codeqr.io/mcp` | | **Authentication** | OAuth 2.0 | | **Authorization URL** | `https://mcp.codeqr.io/oauth/authorize` | | **Token URL** | `https://mcp.codeqr.io/oauth/token` | | **Client ID** | the `client_id` from step 1 | | **Client Secret** | any value — see below | | **Scopes** | `mcp:tools` | | **Enable PKCE Support** | **on** — required | > [!WARNING] > > **PKCE is mandatory.** CodeQR treats every MCP client as public and relies on PKCE instead of a secret, so an authorization request without `code_challenge_method=S256` is rejected before the user ever sees a login screen. If sign-in fails immediately with `PKCE with S256 code_challenge_method is required`, PKCE is off. ### About the client secret CodeQR does not issue one. The registration response says so — `"token_endpoint_auth_method": "none"` — and the token endpoint ignores the field entirely; it authenticates the exchange with PKCE and the registered redirect URI. Gemini Enterprise marks the field as required, so put any placeholder in it. It is neither sent anywhere meaningful nor checked. ## Step 3 — Enable the actions Once the data store reaches **Active**, open it and choose **Actions → Reload custom actions**. Sign in to CodeQR and pick the project to grant access to. The fourteen CodeQR tools appear in the list. Select the ones your team should have and click **Enable actions**. > [!TIP] > > Start with the read-only tools — `list_links`, `list_qrcodes`, `get_analytics`, `get_workspace` — if you want the team exploring before anyone can change a live destination. You can enable the rest later without redoing the connection. ## What your team gets Approving the connection grants CodeQR access scoped to the **single project chosen at sign-in**: read and write on links, QR codes and tags, plus read on analytics and domains. Conversion tracking is not included — see [the note on scopes](/mcp/introduction#what-access-you-grant). Gemini Enterprise caps a data store at **100 enabled actions**; CodeQR uses fourteen, so there is room alongside other servers. ## Troubleshooting > [accordion] Sign-in fails instantly, before any login screen > > PKCE is off. Turn on **Enable PKCE Support** in the connection's authentication settings. CodeQR rejects the authorization request outright without it. > [accordion] redirect\_uri does not match any URI registered for this client > > The callback URL Gemini Enterprise uses is not one you registered in step 1. Copy the exact URL from its setup screen and re-run the registration command with it — you get a new `client_id`, which replaces the one in the connection. > [accordion] Verify Auth fails but the URLs look right > > Confirm the server is reachable from outside your network: > > ```bash theme={null} > curl https://mcp.codeqr.io/health > ``` > > It should answer `{"status":"ok","service":"codeqr-mcp-remote", ...}`. Note that Private Service Connect and VPC Service Controls are not supported by this connector. > [accordion] No actions appear after connecting > > The action list is populated by **Reload custom actions**, not by the connection itself. Run it from the data store once it shows **Active**. # CodeQR MCP server Source: https://docs.codeqr.io/mcp/introduction Connect CodeQR to Claude, Cursor, Gemini Enterprise, and any other MCP client — no API key to copy around. The CodeQR MCP server lets an AI assistant work directly in your workspace: shorten a URL, generate a QR code, change where a printed code points, and read scan and click analytics — without leaving the conversation. It speaks the [Model Context Protocol](https://modelcontextprotocol.io), so any client that supports MCP can connect to it. > [card] Server endpoint > > `https://mcp.codeqr.io/mcp` — Streamable HTTP ## What you can do with it > [card] Create and update links > > Shorten a URL, set a custom slug, add an expiry date, or change a destination after the fact. > [card] Generate QR codes > > Nine content types — URL, WiFi, vCard, WhatsApp, crypto and more — with your own colors and size. > [card] Read analytics > > Scans and clicks grouped by country, device, browser, referrer, or over time. > [card] Organize > > List your custom domains, create tags, and see what your workspace is on. See the [tool reference](/mcp/tools) for all fourteen tools and what each one accepts. ## Connect You do not need an API key. The first request opens your browser, you sign in to CodeQR and pick which project to grant access to, and the client stores the token from there on. > [tab] Claude Code > > ```bash theme={null} > claude mcp add --transport http codeqr https://mcp.codeqr.io/mcp > ``` > > Run `/mcp` inside Claude Code to start the sign-in. > [tab] Claude apps > > In the Claude web or desktop app, open **Customize → Connectors**, click **+ → Add custom connector**, and paste: > > ``` > https://mcp.codeqr.io/mcp > ``` > > Claude registers itself and walks you through sign-in. Leave the OAuth fields under **Advanced settings** empty — CodeQR issues the credentials automatically. > > On Team and Enterprise plans an owner adds the connector once under **Organization settings → Connectors**; members then enable it from **Customize → Connectors** and sign in with their own CodeQR account. > [tab] Cursor > > Add CodeQR to `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (per project): > > ```json theme={null} > { > "mcpServers": { > "codeqr": { > "url": "https://mcp.codeqr.io/mcp" > } > } > } > ``` > [tab] VS Code > > Add CodeQR to `.vscode/mcp.json`: > > ```json theme={null} > { > "servers": { > "codeqr": { > "type": "http", > "url": "https://mcp.codeqr.io/mcp" > } > } > } > ``` Connecting from Gemini Enterprise takes a few extra fields, because that connector asks for a client ID up front instead of registering itself. See [Gemini Enterprise](/mcp/gemini-enterprise). > [!NOTE] > > Every client here uses the same endpoint and the same sign-in. If yours is not listed, point it at `https://mcp.codeqr.io/mcp` over Streamable HTTP — the server advertises everything a client needs to discover on its own. ## Try it Once connected, ask in plain language. Three that exercise different parts of the server: ```text Shorten theme={null} Shorten https://codeqr.io/pricing for me. ``` ```text QR code theme={null} Create a QR code that connects to my WiFi network "Cafe Guest", password "flatwhite", WPA2. Make it dark blue. ``` ```text Analytics theme={null} How many times has my menu QR code been scanned this month? ``` The assistant picks the tool; you approve the call. Anything that overwrites or deletes something already in circulation is marked as such, so your client can warn you before it runs. > [!NOTE] > > Ask for scan counts on **a specific QR code**, as above. Asking for scans broken down by country or device at the workspace level returns clicks across links, QR codes and pages together, not QR scans alone — see [the note on `get_analytics`](/mcp/tools#analytics). ## How sign-in works You never handle an API key. The flow is standard OAuth 2.0, and the client does the work: **1. The client registers itself** On first contact the server answers `401` with a pointer to its metadata, and the client registers via **Dynamic Client Registration** ([RFC 7591](https://datatracker.ietf.org/doc/html/rfc7591)) at `POST /oauth/register`. It gets back a `client_id`. There is no client secret — the server treats every client as public and relies on PKCE instead. **2. You sign in to CodeQR** The client sends you to `/oauth/authorize`, which hands off to CodeQR. You log in, choose the project to grant access to, and approve. **3. The client gets a token** CodeQR returns you to the server, which exchanges the code and issues the client its own token at `POST /oauth/token`. **PKCE with `S256` is required** — a request without a `code_verifier` is rejected. **4. It stays signed in** The CodeQR credentials underneath are refreshed transparently, so you do not sign in again on that client. > [!WARNING] > > **One signed-in client at a time, per CodeQR project.** Signing in from a second client — or re-authorizing the same one — replaces the previous authorization for that project, and the earlier client stops working until it reconnects. If you want CodeQR in two places at once, point each at a different project. The server publishes its own metadata, so a client can discover all of this without being told: ```bash Protected resource theme={null} curl https://mcp.codeqr.io/.well-known/oauth-protected-resource ``` ```bash Authorization server theme={null} curl https://mcp.codeqr.io/.well-known/oauth-authorization-server ``` ### What access you grant Approving the connection grants these scopes on the project you picked: | Area | Access | | - | - | | Links | read and write | | QR codes | read and write | | Analytics | read | | Domains | read | | Tags | read and write | | Your profile | read — your name and picture | Access is scoped to the **one project you choose** during sign-in. To reach a second project, connect again and pick that one. The consent screen spells the same permissions out in more detail, naming read and write on separate lines. > [!WARNING] > > **Conversion tracking is not available through this connection.** Reading conversion data needs a scope that only workspace owners can grant, so including it would lock everyone else out of the connection entirely. Use the [API](/api-reference/introduction) for conversions. ## Troubleshooting > [accordion] The client says the server is unreachable > > Check that it is up: > > ```bash theme={null} > curl https://mcp.codeqr.io/health > ``` > > A healthy server answers `{"status":"ok","service":"codeqr-mcp-remote", ...}`. > [accordion] It connects but never asks me to sign in > > Some clients only start the OAuth flow when a tool is first called. Ask it to do something — "list my short links" — and the browser should open. > [accordion] My client only supports SSE > > This server speaks Streamable HTTP, the current MCP transport. The older SSE transport is not offered. Update the client, or use one from the list above. > [accordion] A tool call fails with a permissions error > > The token is scoped to the single project you picked at sign-in, and to the scopes listed above. If you are trying to reach a different project, reconnect and choose that one. # Tool reference Source: https://docs.codeqr.io/mcp/tools The fourteen tools the CodeQR MCP server exposes, and what each one accepts. Every tool is annotated so your client knows what it does before it runs. Four of them change something already in circulation, and a well-behaved client will ask you to confirm those. | | Meaning | | - | - | | **Read** | Reads only. Changes nothing. | | **Creates** | Creates something publicly reachable. Overwrites nothing. | | **Overwrites** | Changes or removes something already shared or printed. | | **Workspace only** | Writes private workspace state. Nothing on the open web changes. | ## Links > [accordion] create\_link — Create Short Link > > **Creates.** Create a trackable short link. The link is a live endpoint: it keeps resolving after the conversation ends, and its destination can be changed later with `update_link`. > > **url** `string` *required* > > The destination URL to shorten. > > **domain** `string` > > Custom domain. > > **key** `string` > > Custom slug. Auto-generated if omitted. > > **externalId** `string` > > Your own reference ID for the link. > > **tagIds** `string[]` > > Tag IDs to associate. > > **comments** `string` > > Internal notes. > > **expiresAt** `string` > > Expiration date, ISO 8601. > > **password** `string` > > Password-protect the link. > [accordion] list\_links — List Short Links > > **Read.** List all short links in the workspace. > > **search** `string` > > Search keyword. > > **domain** `string` > > Filter by domain. > > **tagId** `string` > > Filter by tag ID. > > **page** `number` > > Page number. > [accordion] get\_link\_info — Get Link Details > > **Read.** Details for one short link. Identify it by `linkId`, by `externalId`, or by `domain` and `key` together — for `codeqr.link/github`, that is domain `codeqr.link` and key `github`. At least one is required. > > **linkId** `string` > > The link ID, as returned by `list_links`. > > **externalId** `string` > > Your own ID for the link, if you set one. > > **domain** `string` > > The link domain. Use with `key`. > > **key** `string` > > The link slug. Use with `domain`. > [accordion] update\_link — Update Short Link > > **Overwrites.** Change where an existing short link points. Anything already shared keeps working and now leads to the new destination — **unless you also change `key`**, which rewrites the link itself and breaks every copy already in circulation. > > **linkId** `string` *required* > > The link ID to update. > > **url** `string` > > New destination URL. > > **key** `string` > > New slug. Breaks existing copies. > > **archived** `boolean` > > Archive status. > > **expiresAt** `string` > > New expiration date. > > **comments** `string` > > Updated comments. > [accordion] delete\_link — Delete Short Link > > **Overwrites.** Delete a short link. Anything already shared stops resolving. > > **linkId** `string` *required* > > The link ID to delete. ## QR codes > [accordion] create\_qrcode — Create QR Code > > **Creates.** Create a dynamic QR code. The printed pattern encodes a short link rather than the content itself, so what it leads to can be changed later without reprinting, and every scan is recorded. > > Pass the payload field matching the `type` you choose. > > **type** `string` > > `url` · `text` · `email` · `phone` · `sms` · `wifi` · `vcard` · `crypto` · `whatsapp`. Defaults to `url`. > > **url** `string` > > For type `url`: the destination the code should lead to. > > **text** `string` > > For type `text`: the plain text to encode. > > **phone** `string` > > For type `phone`: the number to call, e.g. `+5511999999999`. > > **email** `object` > > For type `email`: the message a scan should open. > > **sms** `object` > > For type `sms`: the message a scan should compose. > > **wifi** `object` > > For type `wifi`: the network a scan should join. > > **vcard** `object` > > For type `vcard`: the contact card a scan should offer to save. City, state, zipcode and country are only encoded when `address` is also given. > > **crypto** `object` > > For type `crypto`: the payment request a scan should open. > > **whatsapp** `object` > > For type `whatsapp`: the conversation a scan should open. > > > [!NOTE] > > > > Three sub-fields are named in a way nobody guesses, and a wrong key saves without error and encodes nothing: the recipient in `crypto` is **`address`**, the blind-copy field in `email` is **`cco`**, and `sms` carries a **`subject`**. > > **domain** `string` > > Domain for the underlying short link. > > **key** `string` > > Custom slug for the underlying short link. > > **size** `number` > > Size in pixels. > > **level** `string` > > Error correction level: `L` · `M` · `Q` · `H`. > > **fgColor** `string` > > Foreground color, hex. > > **bgColor** `string` > > Background color, hex. > [accordion] list\_qrcodes — List QR Codes > > **Read.** List all QR codes in the workspace. > > **page** `number` > > Page number. > [accordion] update\_qrcode — Update QR Code > > **Overwrites.** Change what a dynamic QR code leads to without reprinting it: copies already distributed now resolve to the new content. > > Pass the payload field matching the type the code **already has** — `url` for a link code, `wifi` for a Wi-Fi code. A code cannot be converted from one type to another here: sending a `wifi` payload to a `url` code is accepted and silently changes nothing, so check the type with `list_qrcodes` first if you are unsure. > > > [!WARNING] > > > > This does not apply to **static** QR codes, which encode the content directly in the printed pattern. For those the stored record changes, but anything already printed keeps leading to the old content forever. > > **qrcodeId** `string` *required* > > The QR code ID to update. > > **url** `string` > > For a `url` code: the new destination. > > **text** `string` > > For a `text` code: the new plain text. > > **phone** `string` > > For a `phone` code: the new number. > > **email** `object` > > For an `email` code: the new message. > > **sms** `object` > > For an `sms` code: the new message. > > **wifi** `object` > > For a `wifi` code: the new network. > > **vcard** `object` > > For a `vcard` code: the new contact card. > > **crypto** `object` > > For a `crypto` code: the new payment request. > > **whatsapp** `object` > > For a `whatsapp` code: the new conversation. > > **fgColor** `string` > > New foreground color, hex. > > **bgColor** `string` > > New background color, hex. > > **archived** `boolean` > > Archive status. > [accordion] delete\_qrcode — Delete QR Code > > **Overwrites.** Delete a QR code. Any printed copy stops resolving and cannot be recovered by reprinting. > > **qrcodeId** `string` *required* > > The QR code ID to delete. ## Analytics > [accordion] get\_analytics — Get Analytics > > **Read.** Scan and click analytics — workspace-wide, or for one link or QR code. > > **event** `string` *required* > > `clicks` · `scans` · `leads` · `sales` · `composite`. Use `scans` for QR codes and `clicks` for short links. > > **groupBy** `string` *required* > > `count` · `timeseries` · `countries` · `cities` · `devices` · `browsers` · `os` · `referers` · `top_links` · `top_qrcodes` · `top_urls`. > > **linkId** `string` > > Filter by link ID. > > **qrcodeId** `string` > > Filter by QR code ID. > > **domain** `string` > > Filter by domain. > > **key** `string` > > Filter by slug. Use with `domain`. > > **interval** `string` > > `1h` · `24h` · `7d` · `30d` · `90d` · `ytd` · `1y` · `all`. Defaults to `24h`. > > > [!NOTE] > > > > How far back you can look depends on your plan, and a longer window returns `403` rather than a truncated result: **Free** stops at 30 days, **Starter** at 90 days, **Pro** at 1 year, **Business** has no limit. > > > [!WARNING] > > > > **`scans` is only separated from `clicks` for `count` and `timeseries`.** Every other grouping — `countries`, `cities`, `devices`, `browsers`, `os`, `referers` — reports traffic as `clicks` across links, QR codes and pages together, whichever `event` you pass. > > > > To break a QR code's scans down by country, pass its `qrcodeId` so the query is scoped to that one code; read the figure as that code's traffic. For a workspace-wide scan total, use `groupBy: count` or `groupBy: timeseries`, which do separate the three. ## Workspace > [accordion] list\_domains — List Custom Domains > > **Read.** List custom domains configured in the workspace. > > **search** `string` > > Search keyword. > > **page** `number` > > Page number. > > **pageSize** `number` > > Results per page. > [accordion] list\_tags — List Tags > > **Read.** List all tags in the workspace. > > **search** `string` > > Search keyword. > > **page** `number` > > Page number. > > **pageSize** `number` > > Results per page. > [accordion] create\_tag — Create Tag > > **Workspace only.** Create a tag for organizing links. > > **name** `string` *required* > > Tag name. > > **color** `string` > > `red` · `yellow` · `green` · `blue` · `purple` · `pink` · `brown`. > [accordion] get\_workspace — Get Workspace > > **Read.** The workspace this connection is authorized for, including its name, slug and plan. Useful before creating in bulk, or before using a feature the plan may not include. > > Takes no arguments. ## Not available here **Conversion tracking.** `track_lead` and `track_sale` are not exposed. They need the `conversions.write` scope, which cannot be requested without locking non-owners out of the connection entirely. Use the [API](/api-reference/introduction) for conversions. # Client-side click-tracking Source: https://docs.codeqr.io/sdks/client-side/features/client-side-click-tracking Track clicks on the client-side using query parameters With the [`@codeqr/analytics` script](/sdks/client-side/introduction), you can track clicks on the client-side using query parameters (e.g. `?via=john`, `?ref=jane`). A few use cases include: * You're running a referral program with dual-sided incentives and want to display a banner that says: *"John referred you to Acme and gave you 25% off"* * You have dynamically generated referral pages (e.g. [Tesla](https://www.tesla.com/referral/peeroke520149)) and want to track clicks [using a `trackClick()` function](#manually-tracking-clicks-with-the-trackclick-function) inside your application code. * You are migrating from an existing affiliate management platform (e.g. [Rewardful](https://codeqr.io/help/article/migrating-from-rewardful)) that uses query parameters to track conversions. ## Quickstart Here's how you can enable client-side click-tracking with the `@codeqr/analytics` script: **1. Add a custom domain to your CodeQR project** First, you'll need to [add a custom short link domain](https://codeqr.io/help/article/how-to-add-custom-domain) to your CodeQR project. You can use a domain you already own, or leverage our [free .link domain offer](https://codeqr.io/help/article/free-dot-link-domain) to register a custom domain like `yourcompany.link` for free. This is the domain that you'll use for your short links on CodeQR. **2. Allowlist your site's domain** Then, you'll need to allowlist your site's domain to allow the client-side click events to be ingested by CodeQR. To do that, navigate to your [project's Analytics settings page](https://app.codeqr.io/settings/analytics) and add your site's domain to the **Allowed Hostnames** list. ![Enabling conversion tracking for a project](https://mintcdn.com/codeqr/oYQCObrcr5zXAcgg/images/conversions/allowed-hostnames.png?fit=max\&auto=format\&n=oYQCObrcr5zXAcgg\&q=85\&s=3740e9c6c2dc02fada3ba2c0c4b3437e) > [!TIP] > > When testing things out locally, you can add `localhost` to the **Allowed > Hostnames** list temporarily. This will allow local events to be ingested by > CodeQR. Don't forget to remove it once you're ready to go live! **3. Install the CodeQR client-side SDK** Next, install the CodeQR [client-side SDK](/sdks/client-side/introduction) and initialize it with the domain you added in the previous step. ```typescript React/Next.js theme={null} // install the package (e.g. npm install @codeqr/analytics) import { Analytics as CodeQRAnalytics } from "@codeqr/analytics/react"; export default function App() { return ( {/* Your app code here */} ); } ``` ```javascript Other Frameworks theme={null} // include this script tag in your HTML Head tag ``` If you're using referral links for affiliate management, you will also need to set up the `data-domains` property to enable [client-side click-tracking](/sdks/client-side/features/client-side-click-tracking). ```html theme={null} ``` ### Site Visit Variant (`script.site-visit.js`) > [!NOTE] > > `@codeqr/analytics` site visit feature is still in beta. The site visit variant of the script is a variant of the script that supports tracking site visits. On top of the features supported by the base variant, it also supports tracking the first entry page of a user, which is useful for measuring SEO and Google Ads performance. Here's how you can use the site visit variant: ```typescript React theme={null} // the CodeQRAnalytics component automatically detects the `domainsConfig.site` prop // and applies the site-visit script variant for you ``` ```html Other theme={null}