Skip to main content

Embed Endpoint Auto creates an approved affiliate

const embedToken = await wretch("https://api.affonso.io/v1/embed/token")
		.headers({
			Authorization: `Bearer ${env.AFFONSO_API_KEY}`,
			"Content-Type": "application/json",
		})
		.post({
			programId: {env.AFFONSO_PROGRAM_ID},
			partner: {
				email: user.email,
			},
			externalUserId: user.id,
		})
		.json((data: { success: boolean; data?: { publicToken: string } }) => {
			return data.data?.publicToken ?? null;
		})
		.catch((error) => {
			console.error("Error fetching Affonso embed token:", error);
			return null;
		});

I am working on using the embedded dashboard in my service and the above code/endpoint creates an affiliate and puts them as approved despite my program being set as private so they should need my approval? It would be good to either not auto enroll them without a parameter in the body of the post & in the returned data to specify their status e.g. not enrolled, pending etc.

I have not seen an endpoint to query for an affiliate by their email which would allow me to circumvent this issue on a check if the user is signed up/ approved. As stated above this endpoint can be improved so a second is not required.

Currently I cannot embed the dashboard due to this bug.

Status: Completed3 comments

Log in to comment and vote

Comments3

  • Silvestro

    Team•

    Jan 27

    Just deployed the fix.

  • Silvestro

    Team•

    Jan 27

    Thanks a lot for the feedback. All really good points!

    And you're absolutely right. The embed/token endpoint should respect the access mode of the program. If it's set to private, new affiliates should be marked as pending, not auto-approved. I’ll fix that.

    I’ll also extend the GET /affiliates endpoint so you can search by email, not just ID.

    And I agree it’d be useful to include the affiliate’s current status in the embed token response.

    I’ll take care of all three.

    Appreciate you flagging this! 🙏

    • Mark Hardwick

      •

      Jan 27

      Thank you very much 🙏 looking forward to embedding the dashboard.