api key update throws date error

For some reason the API Key update a.k.a auth.api.updateApiKey throws a date error

This is the code:

await auth.api.updateApiKey({
  body: {
    keyId: apiKey.id,
    remaining: Number(apiKey.remaining) - 1,
    userId: context.session.user.id,
  },
});


And this is the schema

export const apikeys = pgTable("api_keys", {
    id: text("id").primaryKey(),
    name: text("name"),
    start: text("start"),
    prefix: text("prefix"),
    key: text("key").notNull(),
    refillInterval: bigint("refill_interval", {
        mode: "bigint",
    }),
    refillAmount: bigint("refill_amount", {
        mode: "bigint",
    }),
    lastRefillAt: timestamp("last_refill_at"),
    enabled: boolean("enabled"),
    rateLimitEnabled: boolean("rate_limit_enabled"),
    rateLimitTimeWindow: bigint("rate_limit_time_window", {
        mode: "bigint",
    }),
    rateLimitMax: bigint("rate_limit_max", {
        mode: "bigint",
    }),
    requestCount: integer("request_count"),
    remaining: integer("remaining"),
    lastRequest: timestamp("last_request"),
    expiresAt: timestamp("expires_at"),
    permissions: text("permissions"),
    metadata: jsonb("metadata"),
    userId: text("user_id")
        .notNull()
        .references(() => users.id, { onDelete: "cascade" }),
    ...timestamps,
});


Have anyone got any issu with this?
CleanShot_2025-05-13_at_01.55.282x.png
Was this page helpful?