# Calling the Binder API in a build pipeline

**URL:** <https://discourse.jupyter.org/t/calling-the-binder-api-in-a-build-pipeline/38115>\
**Category:** Binder\
**Created:** [November 10, 2025, 10:19am UTC](https://discourse.jupyter.org/t/calling-the-binder-api-in-a-build-pipeline/38115 "2025-11-10T10:19:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ekasprzy](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/ekasprzy/32/20291_2.png) [@ekasprzy](https://discourse.jupyter.org/u/ekasprzy)\
**Post date:** [November 10, 2025, 10:19am UTC](https://discourse.jupyter.org/t/calling-the-binder-api-in-a-build-pipeline/38115/1 "2025-11-10T10:19:25Z")

</div>

I have a bunch of private git repos containing jupyter notebooks, and I am looking for a way to autodeploy those notebooks in Jupyter Lab.

I was thus thinking of creating a CI/CD pipeline who would call the /build endpoint of a locally hosted binder after each git commit.  
With the build triggered by a CI/CD pipeline I would have the advantage of having always up to date container images + the ready to use binder badge for end users.

For this to authorize the CI/CD pipeline to call the /build endpoint, since my in-house binder instance has oauth2 authentication enabled.

```auto
        BinderSpawner:
          auth_enabled: true

```

I have thus two questions:  
A) Does this CI/CD calling binder makes sense or should I try something elese ? At least I think I am not the only one who tried that: [Problem Triggering Binder Build through API endpoint](https://discourse.jupyter.org/t/problem-triggering-binder-build-through-api-endpoint/1440)  
Should I consider nbgitpuller as an alternative ?

B) For such a CI / CD pipeline to work againt a binder instance with auth enabled, I would need an API token to call the end point.  
I see JupyterHub has [Using JupyterHub’s REST API — JupyterHub documentation](https://jupyterhub.readthedocs.io/en/latest/howto/rest.html#register-api-tokens-via-configuration).  
Would such a token work with Binder, since the binder auth is delegated to the jupyter hub auth provider ?

---

<div class="post-metadata">

**Author:** ![ekasprzy](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/ekasprzy/32/20291_2.png) [@ekasprzy](https://discourse.jupyter.org/u/ekasprzy)\
**Post date:** [November 11, 2025, 8:59am UTC](https://discourse.jupyter.org/t/calling-the-binder-api-in-a-build-pipeline/38115/2 "2025-11-11T08:59:03Z")

</div>

Answering myself for B)  
Yes calling binder to build using a Jupyter Hub API token works, you need to define an externally service, like `my_external_builder`, and add an entry in [loadRoles](https://z2jh.jupyter.org/en/latest/resources/reference.html#hub-loadroles) like

```auto
        builder_role: # custom service created to allow external calls to binder
          description: access to the hub binder service
          scopes: [read:hub, list:services, access:services!service=binder]
          services: [external_builder]

```

I am struggling now to get binder starting a jupyter server, because binder looks for an `external_builder` user in Jupyter before doing the spawn call and this user is not existing in the user database since it is just a service account.

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [November 11, 2025, 3:35pm UTC](https://discourse.jupyter.org/t/calling-the-binder-api-in-a-build-pipeline/38115/3 "2025-11-11T15:35:16Z")

</div>

I think you’ll need to create a JupyterHub user instead of a service role, and [create an API token](https://jupyterhub.readthedocs.io/en/latest/howto/rest.html#create-an-api-token).

---

<div class="post-metadata">

**Author:** ![ekasprzy](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/ekasprzy/32/20291_2.png) [@ekasprzy](https://discourse.jupyter.org/u/ekasprzy)\
**Post date:** [November 13, 2025, 12:04pm UTC](https://discourse.jupyter.org/t/calling-the-binder-api-in-a-build-pipeline/38115/4 "2025-11-13T12:04:59Z")

</div>

Indeed, with a locally created user with the same name as the service, the binder API /build API call is able to spawn the Pod in Jupyter Hub.  
Thanks for the hint !
