diff --git a/docs/reference/matrix-glib/matrix-glib-sections.txt b/docs/reference/matrix-glib/matrix-glib-sections.txt
index a5f3280..f3db883 100644
--- a/docs/reference/matrix-glib/matrix-glib-sections.txt
+++ b/docs/reference/matrix-glib/matrix-glib-sections.txt
@@ -236,6 +236,7 @@ matrix_presence_event_get_type
MatrixAPI
MatrixAPIInterface
MatrixAPICallback
+MATRIX_API_CALLBACK
MATRIX_API_CALLBACK_PROTO
diff --git a/src/matrix-api.c b/src/matrix-api.c
index 0d6a088..a5ae187 100644
--- a/src/matrix-api.c
+++ b/src/matrix-api.c
@@ -120,6 +120,13 @@
* @raw_content will be set.
*/
+/**
+ * MATRIX_API_CALLBACK:
+ * @f: a function pointer
+ *
+ * Cast a function pointer to a #MatrixAPICallback.
+ */
+
/**
* MATRIX_API_CALLBACK_PROTO:
* @name: the name of the function
diff --git a/src/matrix-api.h b/src/matrix-api.h
index 1bd6f5e..413844f 100644
--- a/src/matrix-api.h
+++ b/src/matrix-api.h
@@ -41,6 +41,8 @@ typedef void (*MatrixAPICallback)(MatrixAPI *api,
gpointer user_data,
GError *err);
+#define MATRIX_API_CALLBACK(f) ((MatrixAPICallback) (f)
+
#define MATRIX_API_CALLBACK_PROTO(name) static void \
name (MatrixAPI *api, \
const gchar *content_type, \