JeffWScottJ
Convex Community5mo ago
6 replies
JeffWScott

/api/action returning 404

Hello,
I have a convex deployment and I'm trying to send some data to my table using an action from a go program.

From the docs it looks straightforwards but I was having some truouble.

So I set up a simple action that just prints Hello to teh console. This action runs in the dashboard manually.

When I call this function from my go code I get "HTTP error 404: This Convex deployment does not have HTTP actions enabled."

I don't see anywhere to "enable HTTP actions".

this is my action:
// convex/items.ts
export const testHttpActions = action({
    args: {},
    handler: async () => {
        console.log("ACTION!")
    },
});


This is my go code code:

...
    url := "https://<removed_from_example>.convex.site/api/action"

    body := map[string]interface{}{
        "path":   "items:testHttpActions",
        "args":   "",
        "format": "json",
    }

    jsonBody, err := json.Marshal(body)
    if err != nil {
        return err
    }

    req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonBody))
    if err != nil {
        return err
    }
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", CONVEX_API_KEY))

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        return err
    }
    defer resp.Body.Close()
...


When I google this error or talk to AI about it I get a lot of stuff about setting up "http actions" but that's not what I want to do.

I want to do what's in this documentation:
https://docs.convex.dev/http-api/#functions-api

Can someone help me understand please? I thought this was going to be pretty straightforward by looking at the docs and now i'm just spinning.
Connecting to Convex directly with HTTP
Convex HTTP API | Convex Developer Hub
Was this page helpful?